master #173

Merged
Maxime merged 71 commits from Maxime/Clyde:master into master 2024-04-22 00:07:00 +02:00
3 changed files with 36 additions and 30 deletions
Showing only changes of commit e998fb2ab4 - Show all commits

View File

@ -2,8 +2,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";
import { fetchAllResearches, addView} from "@/rest/ScientificPublications/ManageResearch.js";
const input = ref("")
const isFilterOpened = ref(false);
const isResearchOpened = ref(false);
@ -34,23 +33,6 @@ const closeResearch = () => {
articleToDisplay.value = null;
}
const downloadBibTex = (research) => {
getFile(research.bibTexLocation)
}
async function downloadArticle (research){
await addView(research.pdfLocation)
await getFile(research.pdfLocation)
articleToDisplay.value = await fetchResearch(articleToDisplay.value.id)
}
function downloadCoAuthors(){
//todo
const data = JSON.stringify(researcher.value);
const blob = new Blob([data], {type:"application/json"});
return URL.createObjectURL(blob);
}
function searchInList(list, searchInput) {
let retList = []
@ -91,7 +73,7 @@ function lDistance(s,t){
<template>
<div id="main">
<FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" :manage="false" @modal-close="closeResearch" @downloadPdf="downloadArticle(articleToDisplay)" @downloadBibTex="downloadBibTex(articleToDisplay)"></ArticleComponent>
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" :manage="false" @modal-close="closeResearch" ></ArticleComponent>
<div id="researches">
<div id="search">
<input v-if="!isResearcher" type="text" id="search-input" placeholder="search for researches" v-model="input"/>

View File

@ -8,13 +8,17 @@
<script setup xmlns="http://www.w3.org/1999/html">
import {ref } from "vue";
import {onClickOutside} from '@vueuse/core'
import {patchArticle, deleteArticle} from "@/rest/ScientificPublications/ManageResearch.js";
import {patchArticle, deleteArticle, addView} from "@/rest/ScientificPublications/ManageResearch.js";
const restURL = import.meta.env.VITE_CLYDE_MODE === 'container' ? "http://localhost:8000": import.meta.env.DEV ? "http://localhost:5173" : "https://clyde.herisson.ovh/api"
const props = defineProps({
isOpen: Boolean,
article: ref(Object),
manage:Boolean,
});
function format(date){
let split = date.split("-")
let month = split[1]
@ -23,7 +27,7 @@ function format(date){
return day +"/"+ month +"/"+ year
}
const emit = defineEmits(["modal-close","downloadPdf","downloadBibTex","modified"]);
const emit = defineEmits(["modal-close","modified"]);
const target = ref(null)
onClickOutside(target, ()=>emit('modal-close'))
@ -34,6 +38,7 @@ function cancelChanges(){
toModify= Object.assign({}, {});
emit('modal-close')
}
async function confirmChanges(){
await patchArticle(props.article.id, toModify)
toModify= Object.assign({}, {});
@ -46,7 +51,26 @@ async function deleteThisArticle(){
emit('modal-close')
emit("modified")
}
function downloadPdf(){
return (restURL + "/" + props.article.pdfLocation)
}
function downloadBibTex(){
return (restURL + "/" + props.article.bibTexLocation)
}
async function articleClicked(){
await addView(props.article.pdfLocation)
emit('modal-close')
}
/**
function downloadCoAuthors(){
//todo
const data = JSON.stringify(researcher.value);
const blob = new Blob([data], {type:"application/json"});
return URL.createObjectURL(blob);
} **/
</script>
@ -55,7 +79,6 @@ async function deleteThisArticle(){
<div class="modal-wrapper">
<div class="modal-container" ref="target">
<div ><ul>
<li>Article Id : {{article.id}}</li>
<li>Title : {{article.title}}</li>
<li>Author : {{article.researcher.user.lastName + " " + article.researcher.user.firstName}}</li>
@ -67,11 +90,10 @@ async function deleteThisArticle(){
<li>Views : {{article.views}}</li>
<li>Access : {{article.access}}</li>
</ul>
<div id="downloads" v-if="article.pdfLocation !== null && !manage">
<button @click.stop="emit('downloadBibTex')">Download BibTex</button>
<button @click.stop="emit('downloadPdf')">Download Research</button>
</div>
<button @click="console.log(props.article)"> infos</button>
<div id="downloads" v-if="article !== null && !manage">
<a :href=downloadPdf() @click.stop="articleClicked" target="_blank">See Research</a>
<a :href=downloadBibTex() @click.stop="emit('modal-close')" target="_blank">See bibTex</a> </div>
</div>
<div v-if="manage">
<div>
@ -125,7 +147,7 @@ async function deleteThisArticle(){
#downloads {
text-align: end;
}
#downloads button {
#downloads a {
align-self: center;
margin-left: 2px;
font-size: large;
@ -133,6 +155,8 @@ async function deleteThisArticle(){
background: rgba(191, 64, 191,0.5);
border:2px solid black;
border-radius: 5px;
text-underline-mode: none;
text-decoration: none;
}
#downloads button:hover{
background: rgba(191, 64, 191);

View File

@ -29,7 +29,7 @@ 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"})
return await fetch(restURL + "/" + url, {method: "GET"})
}
export async function addView(url){
return restPost("/addview/" + url)