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),
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",
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",
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);

View File

@ -73,6 +73,25 @@ public class ResearchController {
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
*
* @return the research saved

View File

@ -1,6 +1,8 @@
package ovh.herisson.Clyde.Repositories.ScientificPublications;
import org.springframework.data.jpa.repository.Query;
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.User;
@ -8,4 +10,7 @@ public interface ResearcherRepository extends CrudRepository<Researcher,Long> {
Researcher findByUser(User user);
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')")
Iterable<Map<String ,Integer>> viewsByMonths();
/**
Iterable<Map<String ,Integer>> viewsByYears();
Iterable<Map<String ,Integer>> viewsByTopics();
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>> researchesByTopics();
Iterable<Map<String ,Integer>> researchesByMonth();
**/
}

View File

@ -42,6 +42,13 @@ public class ResearchesService {
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){

View File

@ -7,18 +7,71 @@
<script setup>
import { ref } from "vue";
import {onClickOutside} from '@vueuse/core'
import {w} from "../../../dist/assets/_plugin-vue_export-helper-Bvj9NrzX.js";
let checked = ref([])
const yearList = ref([])
const monthList = ref([])
const accessList = ref([])
const languageList = ref([])
const domainList = ref([])
const paperTypeList = ref([])
const props = defineProps({
isOpen: Boolean,
allArticles: ref([Object])
});
const example = ["A","B", "Lorem Ipsum AAAAAAAAAAAAAAAAAAA",
"H",
"H",
"H",
"H",
"H",
]
for (let i=0;i< props.allArticles.length;i++) {
let r = props.allArticles[i];
let year = r.releaseDate.split("-")[0]
let month = r.releaseDate.split("-")[1]
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 target = ref(null)
@ -31,15 +84,15 @@ onClickOutside(target, ()=>emit('modal-close'))
<div class="modal-wrapper">
<div class="modal-container" ref="target">
<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 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"> example :<ul class="checkers"> <li v-for="n in example"> <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 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"> 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"> 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"> Language :<ul class="checkers"> <li v-for="n in languageList"> <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"> 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"> PaperType :<ul class="checkers"> <li v-for="n in paperTypeList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
</div>
<div id="submit">
<button @click.stop="emit('modal-close')">Submit</button>
<button @click.stop="emit('modal-close', 'submit')">Submit</button>
</div>
</div>
</div>

View File

@ -8,16 +8,20 @@
<script setup>
import {ref } from "vue";
import {onClickOutside} from '@vueuse/core'
let checked = ref([])
const props = defineProps({
isOpen: Boolean,
article: ref(Object)
});
const example = ["Title","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",
]
function format(date){
let split = date.split("-")
let month = split[1]
let day = split[2].split("T")[0]
let year = split[0]
return day +"/"+ month +"/"+ year
}
const emit = defineEmits(["modal-close"]);
const target = ref(null)
@ -29,8 +33,19 @@ onClickOutside(target, ()=>emit('modal-close'))
<div v-if="isOpen" class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container" ref="target">
<ul v-for="n in example"><li>{{n}}</li></ul>
<div id="downloads">
<ul>
<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 Research</button>
</div>
@ -59,6 +74,10 @@ onClickOutside(target, ()=>emit('modal-close'))
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
}
.modal-container ul{
margin-top: 9px;
}
#downloads {
text-align: end;

View File

@ -9,13 +9,23 @@
import { ref, reactive } from "vue";
import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
import {fetchResearcher, fetchResearches} from "@/rest/ScientificPublications/ResearcherProfile.js";
const input = ref("");
const statsOf = ref("");
const statsBy = ref("");
const isFilterOpened = ref(false);
const isResearchOpened = ref(false);
const articleToDisplay = ref(Object)
const filters = ref([""])
const researchList = ref(await fetchResearches(1))
let chart;
const props = defineProps({
researcher: ref(Object),
filters: ref([""]),
});
const openFilter = () => {
isFilterOpened.value = true;
};
@ -23,14 +33,15 @@ const closeFilter = () => {
isFilterOpened.value = false;
};
const submitFilters = ()=>{
// call only with those filters the get
}
const openResearch = (article) => {
isResearchOpened.value = true;
articleToDisplay.value = article;
}
const closeResearch = () => {
isResearchOpened.value =false;
articleToDisplay.value = null;
}
const downloadBibTex = (research) => {
@ -40,25 +51,14 @@ const downloadBibTex = (research) => {
const downloadArticle = (research) => {
//todo
}
//todo changer dynamiquement le 1 ici en fct de sur quel profil on est
const researcher = ref(await fetchResearcher(1))
const researchList = [
["The Great Potato War Lorem Ipsum aeaDq Terelumni ","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 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",
],
]
function downloadCoAuthors(){
const data = JSON.stringify(researcher.value);
const blob = new Blob([data], {type:"application/json"});
return URL.createObjectURL(blob);
}
const jsonMockViewsByYears= [
@ -71,13 +71,9 @@ const jsonMockViewsByYears= [
function searchInList(list, searchInput) {
let retList = []
if (searchInput === ""){
list.forEach(r => retList.push(r.slice(0, 2)))
return retList
}
for (let i = 0; i < list.length; i++) {
if (lDistance(list[i][0], searchInput) < 10 || list[i][0].toUpperCase().indexOf(searchInput.toUpperCase()) > -1){
retList.push(list[i].slice(0,2))
if (lDistance(list[i].title, searchInput) < 10 || list[i].title.toUpperCase().indexOf(searchInput.toUpperCase()) > -1){
retList.push(list[i])
}
}
return retList
@ -138,22 +134,20 @@ function update(){
<template>
<div id="main">
<FilterComponent :isOpen="isFilterOpened" @modal-close="closeFilter" @submit="submitFilters"></FilterComponent>
<ArticleComponent :isOpen="isResearchOpened" @modal-close="closeResearch"></ArticleComponent>
<FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" @modal-close="closeResearch"></ArticleComponent>
<div id="profilePicture">
<img src="/Clyde.png" />
</div>
<div id="researcherInfos">
<div class="surrounded">John Doe</div>
<div class="surrounded">Orcid : 12144-2144-12336-B</div>
<div class="surrounded">Email : John.Doe@umons.ac.be</div>
<div class="surrounded">{{researcher.user.lastName}} {{researcher.user.firstName}}</div>
<div class="surrounded">Orcid : {{researcher.orcidId}}</div>
<div class="surrounded">Email : {{researcher.user.email}}</div>
<div class="surrounded">
site :
<a href="http://localhost:5173" style="color: #007aff">here</a>
site : <a :href=researcher.site style="color: #007aff"> {{researcher.site}}</a>
</div>
<div class="surrounded">Domain : physics, IT</div>
<div id="coAuthorList" class="surrounded">Co-authors list : D</div>
<div class="surrounded">Domain : {{researcher.domain}}</div>
<div id="coAuthorList" class="surrounded">Co-authors list : <a :href=downloadCoAuthors() download="coAuthors.json"> here </a></div>
</div>
<div id="stats">
<div class="surrounded">
@ -184,9 +178,9 @@ function update(){
</div>
<ul id="researchUL">
<li id="researchLi" v-for="n in searchInList(researchList,input)">
<div class="vl"> {{n[0]}}</div>
<div class="vl"> {{n[1]}}</div>
<a @click="openResearch"> MoreInfo </a></li>
<div class="vl"> {{n.title}}</div>
<div class="vl"> {{ n.researcher.user.firstName +" "+ n.researcher.user.lastName }}</div>
<a @click="openResearch(n)"> MoreInfo </a></li>
</ul>
</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)
}