added addview and download PDF
This commit is contained in:
parent
388c53e47b
commit
821377a72f
@ -225,4 +225,16 @@ public class ResearchController {
|
|||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////
|
||||||
|
//views part
|
||||||
|
@PostMapping("/addView{url}")
|
||||||
|
public ResponseEntity<ResearchDTO> addView(@PathVariable String url){
|
||||||
|
Research research = researchesServ.getResearchByUrl(url);
|
||||||
|
if (research ==null) return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(ResearchDTO.construct(researchesServ.addView(research)), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,6 @@ public interface ResearchRepository extends CrudRepository<Research,Long> {
|
|||||||
|
|
||||||
Iterable<Research> findByAuthor(Researcher author);
|
Iterable<Research> findByAuthor(Researcher author);
|
||||||
|
|
||||||
|
Research findByPdfLocation(String url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
|
||||||
@Query("select new map(to_char(r.releaseDate,'year') as label, sum (r.views) as y) from Research r group by to_char(r.releaseDate,'year')")
|
@Query("select new map(to_char(r.releaseDate,'YYYY') as label, sum (r.views) as y) from Research r group by to_char(r.releaseDate,'YYYY')")
|
||||||
Iterable<Map<String ,Integer>> viewsByYears();
|
Iterable<Map<String ,Integer>> viewsByYears();
|
||||||
|
|
||||||
|
|
||||||
@ -19,16 +19,16 @@ public interface StatsRepository extends CrudRepository<Research,Long> {
|
|||||||
Iterable<Map<String ,Integer>> viewsByTopics();
|
Iterable<Map<String ,Integer>> viewsByTopics();
|
||||||
|
|
||||||
|
|
||||||
@Query("select new map(r.domain as label, r.language as y) from Research r group by r.domain")
|
@Query("select new map(r.domain as label, count(r.language) as y) from Research r group by r.domain")
|
||||||
Iterable<Map<String ,Integer>> languageByTopics();
|
Iterable<Map<String ,Integer>> languageByTopics();
|
||||||
|
|
||||||
@Query("select new map(to_char(r.releaseDate,'year') as label, r.language as y) from Research r group by to_char(r.releaseDate,'year')")
|
@Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(r.language) as y) from Research r group by to_char(r.releaseDate,'YYYY')")
|
||||||
Iterable<Map<String ,Integer>> languageByYears();
|
Iterable<Map<String ,Integer>> languageByYears();
|
||||||
|
|
||||||
@Query("select new map(to_char(r.releaseDate, 'month') as label, r.language as y) from Research r group by to_char(r.releaseDate, 'month')")
|
@Query("select new map(to_char(r.releaseDate, 'month') as label, count(r.language) as y) from Research r group by to_char(r.releaseDate, 'month')")
|
||||||
Iterable<Map<String ,Integer>> languageByMonths();
|
Iterable<Map<String ,Integer>> languageByMonths();
|
||||||
|
|
||||||
@Query("select new map(to_char(r.releaseDate,'year') as label, count(r) as y) from Research r group by to_char(r.releaseDate,'year')")
|
@Query("select new map(to_char(r.releaseDate,'YYYY') as label, count(r) as y) from Research r group by to_char(r.releaseDate,'YYYY')")
|
||||||
Iterable<Map<String ,Integer>> researchesByYears();
|
Iterable<Map<String ,Integer>> researchesByYears();
|
||||||
|
|
||||||
@Query("select new map(r.domain as label, count(r) as y) from Research r group by r.domain")
|
@Query("select new map(r.domain as label, count(r) as y) from Research r group by r.domain")
|
||||||
|
@ -2,6 +2,7 @@ package ovh.herisson.Clyde.Services.ScientificPublications;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ovh.herisson.Clyde.DTO.ScientificPublications.ResearchDTO;
|
||||||
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearchCoAuthorsRepository;
|
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearchCoAuthorsRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearchRepository;
|
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearchRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearcherRepository;
|
import ovh.herisson.Clyde.Repositories.ScientificPublications.ResearcherRepository;
|
||||||
@ -186,4 +187,13 @@ public class ResearchesService {
|
|||||||
}
|
}
|
||||||
researcherRepo.save(researcher);
|
researcherRepo.save(researcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Research getResearchByUrl(String url) {
|
||||||
|
return articleRepo.findByPdfLocation(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Research addView(Research research) {
|
||||||
|
research.setViews(research.getViews()+1);
|
||||||
|
articleRepo.save(research);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ public class StatisticsService {
|
|||||||
toReturn.add(statsRepo.languageByYears());
|
toReturn.add(statsRepo.languageByYears());
|
||||||
toReturn.add(statsRepo.languageByMonths());
|
toReturn.add(statsRepo.languageByMonths());
|
||||||
toReturn.add(statsRepo.languageByTopics());
|
toReturn.add(statsRepo.languageByTopics());
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ function format(date){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const emit = defineEmits(["modal-close"]);
|
const emit = defineEmits(["downloadPdf","downloadBibTex"]);
|
||||||
|
|
||||||
const target = ref(null)
|
const target = ref(null)
|
||||||
onClickOutside(target, ()=>emit('modal-close'))
|
onClickOutside(target, ()=>emit('modal-close'))
|
||||||
@ -43,11 +43,12 @@ onClickOutside(target, ()=>emit('modal-close'))
|
|||||||
<li>PaperType : {{article.paperType}}</li>
|
<li>PaperType : {{article.paperType}}</li>
|
||||||
<li>Domain : {{article.domain}}</li>
|
<li>Domain : {{article.domain}}</li>
|
||||||
<li>Access : {{article.access}}</li>
|
<li>Access : {{article.access}}</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<div id="downloads" v-if="article.pdfLocation !== null">
|
<div id="downloads" v-if="article.pdfLocation !== null">
|
||||||
<button @click.stop="emit('modal-close')">Download BibTex</button>
|
<button @click.stop="emit('downloadBibTex')">Download BibTex</button>
|
||||||
<button @click.stop="emit('modal-close')">Download Research</button>
|
<form method="get" :action=article.pdfLocation>
|
||||||
|
<button @click.stop="emit('downloadPdf', article)">Download Research</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
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";
|
import {fetchResearcher, fetchResearches, fetchStats, addView} from "@/rest/ScientificPublications/ResearcherProfile.js";
|
||||||
const input = ref("");
|
const input = ref("");
|
||||||
const statsOf = ref("");
|
const statsOf = ref("");
|
||||||
const statsBy = ref("");
|
const statsBy = ref("");
|
||||||
@ -17,16 +17,15 @@ const isFilterOpened = ref(false);
|
|||||||
const isResearchOpened = ref(false);
|
const isResearchOpened = ref(false);
|
||||||
const articleToDisplay = ref(Object)
|
const articleToDisplay = ref(Object)
|
||||||
const filters = ref([]);
|
const filters = ref([]);
|
||||||
const researchList = ref(await fetchResearches(1));
|
|
||||||
let chart;
|
let chart;
|
||||||
|
|
||||||
|
const researchList = ref(await fetchResearches(1));
|
||||||
//todo changer dynamiquement le 1 ici en fct de sur quel profil on est
|
//todo changer dynamiquement le 1 ici en fct de sur quel profil on est
|
||||||
const researcher = ref(await fetchResearcher(1));
|
const researcher = ref(await fetchResearcher(1));
|
||||||
|
const stats = ref(await fetchStats(1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
researcher: ref(Object),
|
researcherId: ref(), //int
|
||||||
filters: ref([""]),
|
filters: ref([""]),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,7 +52,8 @@ const downloadBibTex = (research) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const downloadArticle = (research) => {
|
const downloadArticle = (research) => {
|
||||||
//todo
|
addView(research.url)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadCoAuthors(){
|
function downloadCoAuthors(){
|
||||||
@ -63,14 +63,6 @@ function downloadCoAuthors(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const jsonMockViewsByYears= [
|
|
||||||
{label: "2004", y:4},
|
|
||||||
{label: "2005", y:99},
|
|
||||||
{label: "2007", y:555},
|
|
||||||
{label: "2009", y:22},
|
|
||||||
{label: "2011", y:1666},
|
|
||||||
]
|
|
||||||
|
|
||||||
function searchInList(list, searchInput) {
|
function searchInList(list, searchInput) {
|
||||||
let retList = []
|
let retList = []
|
||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
@ -121,23 +113,25 @@ const options = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function update(){
|
function update(){
|
||||||
options.title = {
|
options.title = {
|
||||||
fontColor: "white",
|
fontColor: "white",
|
||||||
text: statsOf.value + " By "+ statsBy.value,
|
text: statsOf.value + " By "+ statsBy.value,
|
||||||
}
|
}
|
||||||
if (statsOf.value === "views" && statsBy.value === "years") {
|
const index = (0 ?statsOf.value === "views": 3 ? statsOf.value === "researches":6) + (0?statsBy.value ==="years":1?statsBy.value==="months":2)
|
||||||
options.data[0].dataPoints = jsonMockViewsByYears;
|
|
||||||
}
|
|
||||||
|
|
||||||
options.title.text = statsOf.value + " By "+ statsBy.value;
|
|
||||||
chart.render()
|
options.data[0].dataPoints = stats.value[index]
|
||||||
}
|
|
||||||
|
|
||||||
|
options.title.text = statsOf.value + " By "+ statsBy.value;
|
||||||
|
chart.render();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
|
<FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
|
||||||
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" @modal-close="closeResearch"></ArticleComponent>
|
<ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" @modal-close="closeResearch" @downloadPdf="downloadArticle" @downloadBibTex="downloadBibTex"></ArticleComponent>
|
||||||
<div id="profilePicture">
|
<div id="profilePicture">
|
||||||
<img src="/Clyde.png" />
|
<img src="/Clyde.png" />
|
||||||
</div>
|
</div>
|
||||||
@ -157,13 +151,13 @@ function update(){
|
|||||||
<select @change="update()" id="stats-select" v-model="statsOf">
|
<select @change="update()" id="stats-select" v-model="statsOf">
|
||||||
<option value="views">Views</option>
|
<option value="views">Views</option>
|
||||||
<option value="researches">Researches</option>
|
<option value="researches">Researches</option>
|
||||||
<option value="language">Languages</option>
|
<option value="languages">Languages</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="surrounded">
|
<div class="surrounded">
|
||||||
Class by:
|
Class by:
|
||||||
<select @change="update()" id="classed-select" v-model="statsBy">
|
<select @change="update()" id="classed-select" v-model="statsBy">
|
||||||
<option selected="selected" value="years">Years</option>
|
<option value="years">Years</option>
|
||||||
<option value="months">Months</option>
|
<option value="months">Months</option>
|
||||||
<option value="topics">Topics</option>
|
<option value="topics">Topics</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -8,4 +8,10 @@ export async function fetchResearches(id){
|
|||||||
return restGet("/researches/" + id)
|
return restGet("/researches/" + id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchStats(id){
|
||||||
|
return restGet("/stats/" +id)
|
||||||
|
}
|
||||||
|
export async function addView(url){
|
||||||
|
return restPost("/addView/" +url)
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user