This commit is contained in:
2023-03-31 17:23:49 +02:00
13 changed files with 1749 additions and 3659 deletions

View File

@@ -23,6 +23,7 @@
</div>
<script>
export default {
onBeforeMount(props, state) {
state = {
@@ -36,22 +37,20 @@
}
},
onBeforeUpdate(props, state) {
if (!props.schoolList || !props.schoolList.length) return
let list = props.schoolList
updateFiliStats() {
let list = this.props.schoolList
let avg = list.reduce((s, e) => s + e.fields.moyenne, 0) / list.length
let avgCap = list.reduce((s, e) => s + e.fields.capa_fin, 0) / list.length
let avgSlc = list.reduce((s, e) => s + (e.fields.taux_acces_ens || 0), 0) / list.filter((e) => e.fields.taux_acces_ens).length
state.courseNumber = list.length
state.average = Math.round(avg * 100) / 100
state.capacity = Math.floor(avgCap)
state.selectivity = Math.floor(avgSlc)
this.state.courseNumber = list.length
this.state.average = Math.round(avg * 100) / 100
this.state.capacity = Math.floor(avgCap)
this.state.selectivity = Math.floor(avgSlc)
let pctFemmes = Math.round(list.reduce((s, e) => s + (e.fields.pct_f || 0), 0) / list.filter((e) => e.fields.pct_f).length)
state.genreStats = [
this.state.genreStats = [
{
name: "Hommes",
short: "H",
@@ -67,8 +66,11 @@
let pctBG = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_gen || 0), 0) / list.filter((e) => e.fields.part_acces_gen).length)
let pctBT = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_tec || 0), 0) / list.filter((e) => e.fields.part_acces_tec).length)
let pctBP = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_pro || 0), 0) / list.filter((e) => e.fields.part_acces_pro).length)
state.bacStats = [
if (!pctBG) pctBG = 0;
if (!pctBT) pctBT = 0;
if (!pctBP) pctBP = 0;
this.state.bacStats = [
{
name: "Général",
short: "Gen.",
@@ -97,7 +99,7 @@
let pctTB = Math.round(list.reduce((s, e) => s + e.fields.pct_tb, 0) / list.length)
let pctTBF = Math.round(list.reduce((s, e) => s + e.fields.pct_tbf, 0) / list.length)
state.mentionStats = [
this.state.mentionStats = [
{
name: "Sans Mention",
short: "SM",
@@ -129,6 +131,11 @@
value: 100 - (pctSM + pctAB + pctB + pctTB + pctTBF)
}
]
},
onBeforeUpdate(props, state) {
if (!props.schoolList || !props.schoolList.length) return
this.updateFiliStats()
}
}
</script>

View File

@@ -5,9 +5,10 @@
<img class="m-auto" src="./resources/logo-parcoursup.svg"/>
</div>
<search updateCourse={updateCourse}></search>
<button class="button is-danger ml-2 is-outlined" onclick={clearCache}>Vider le cache</button>
</div>
<div class="column">
<div class="column pl-0">
<fili-info schoolList={state.schoolList} course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info>
<school popup={popup} schoolList={state.schoolList} schoolListUpdating={state.schoolListUpdating} course={state.course} shouldShowInfos={state.shouldShowInfos}></school>
</div>
@@ -25,7 +26,7 @@
this.update({
course: course,
shouldShowInfos: course != null,
shouldShowInfos: course != null
})
},
@@ -59,12 +60,21 @@
onMounted(props, state) {
this.update({
course: null,
schoolList: [],
school: null,
schoolList: null,
popupEnabled: false,
shouldShowInfos: false
})
},
clearCache(e) {
localStorage.clear()
e.target.textContent = "Cache vidé !"
setTimeout(() => {
e.target.textContent = "Vider le cache"
}, 3000)
},
popup(school){
this.update({
school: school,

View File

@@ -1,5 +1,5 @@
<school-info>
<div if={props.popupEnabled} class="modal is-active">
<div if={props.popupEnabled} style="z-index: 10000" class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<div class="box p-2">

View File

@@ -1,15 +1,13 @@
<school>
<div if={props.shouldShowInfos} class="box p-2 m-2" disabled="true">
<iframe if={false} width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik"
style="border-radius: 5px;"></iframe>
<div class="block control has-icons-left is-inline-block is-pulled-right">
<div id="map" width="100%" style="border-radius: 5px"></div>
<div class="mt-2 mb-2 control has-icons-left is-inline-block is-pulled-right">
<input class="input" onkeyup={filterSearch} type="search" placeholder="Établissement">
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
</div>
<table class="table is-fullwidth is-hoverable">
<table class="table is-fullwidth is-hoverable is-narrow">
<thead>
<tr>
<th each={sortField in sortFields}>
@@ -37,7 +35,7 @@
const SORT_TABLE = [
{name: "Nom", id: "g_ea_lib_vx"},
{name: "Ville", id: "ville_etab"},
{name: "Département", id: "dep"},
{name: "Dept.", id: "dep"},
{name: "Moyenne", id: "moyenne"},
{name: "Sélectivité", id: "taux_acces_ens"}
]
@@ -103,6 +101,44 @@
}
},
onUpdated(props, state) {
if (!state.map && props.shouldShowInfos) {
state.map = L.map("map").setView([47, 2.5], 5)
state.markers = L.markerClusterGroup()
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(state.map);
} else (state.map) {
state.markers.clearLayers()
for (let school of state.filteredSchoolList) {
let fields = school.fields
let pos = fields.g_olocalisation_des_formations
let popupHTML = document.createElement("div")
let title = document.createElement("span")
title.textContent = fields.g_ea_lib_vx
title.class = "is-primary"
let linkToForma = document.createElement("a")
linkToForma.onclick = () => props.popup(school)
linkToForma.textContent = "Voir les infos de l'établissement"
popupHTML.appendChild(title)
popupHTML.appendChild(document.createElement("br"))
popupHTML.appendChild(linkToForma)
let marker = L.marker(pos)
marker.bindPopup(popupHTML)
state.markers.addLayer(marker)
}
state.map.addLayer(state.markers)
}
},
onBeforeMount(props, state) {
this.state = {
sortBy: null,