Gros progrès, statistiques 80%, reste à faire le school-info
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@ var lineGraph = {
|
||||
exports: {
|
||||
updateCanvas() {
|
||||
let canvas = this.$("canvas");
|
||||
if (!canvas) return;
|
||||
if (!canvas || !this.props.data || !this.props.title) return;
|
||||
canvas.width = canvas.clientWidth;
|
||||
canvas.height = canvas.clientHeight;
|
||||
let cx = canvas.getContext("2d");
|
||||
@@ -12,8 +12,8 @@ var lineGraph = {
|
||||
let width = canvas.width;
|
||||
let height = canvas.height;
|
||||
let spacing = 1;
|
||||
let data = this.state.data;
|
||||
let colors = ["#003F5C", "#2F4B7C", "#665191", "#A05195", "#D45087"];
|
||||
let data = this.props.data;
|
||||
let colors = ["#003F5C", "#2F4B7C", "#665191", "#A05195", "#D45087", "#D47150"];
|
||||
cx.clearRect(0, 0, width, height);
|
||||
cx.resetTransform();
|
||||
if (!data) return;
|
||||
@@ -27,39 +27,38 @@ var lineGraph = {
|
||||
let counter = 0;
|
||||
let legendWidth = 0;
|
||||
for (let field of data) {
|
||||
if (field.value == 0) continue;
|
||||
let start = curr + spacing;
|
||||
let barWidth = field.value / total * width - spacing * 2;
|
||||
let text = `${Math.round(field.value / total * 1000) / 10}% (${field.name})`;
|
||||
let text = `${Math.round(field.value / total * 1000) / 10}% (${field.short || field.name})`;
|
||||
cx.fillStyle = colors[counter];
|
||||
cx.fillRect(start, 0, barWidth, height / 3);
|
||||
cx.fillStyle = "#FFFFFF";
|
||||
if (cx.measureText(text).width < barWidth) {
|
||||
cx.fillText(text, start + barWidth / 2, height / 6);
|
||||
} else if (cx.measureText("...").width < barWidth) {
|
||||
cx.fillText("...", start + barWidth / 2, height / 6);
|
||||
} else if (cx.measureText(`${Math.round(field.value / total * 1000) / 10}%`).width < barWidth) {
|
||||
cx.fillText(`${Math.round(field.value / total * 1000) / 10}%`, start + barWidth / 2, height / 6);
|
||||
}
|
||||
curr += field.value / total * width;
|
||||
counter++;
|
||||
legendWidth += cx.measureText(field.name).width + 25 + 15; // += textWidth + squareWidth + margin
|
||||
let legendText = field.name + (field.short ? ` (${field.short})` : "");
|
||||
legendWidth += cx.measureText(legendText).width + 25 + 15;
|
||||
}
|
||||
|
||||
cx.textAlign = "left";
|
||||
legendWidth -= 15; //On enlève la dernière marge
|
||||
cx.translate(width / 2 - legendWidth / 2, height / 4 + 20);
|
||||
counter = 0;
|
||||
for (let field of data) {
|
||||
if (field.value == 0) continue;
|
||||
cx.fillStyle = colors[counter];
|
||||
cx.fillRect(0, 0, 25, 25);
|
||||
cx.fillStyle = "#707070";
|
||||
cx.fillText(field.name, 30, 12.5);
|
||||
cx.translate(cx.measureText(field.name).width + 25 + 15, 0);
|
||||
let legendText = field.name + (field.short ? ` (${field.short})` : "");
|
||||
cx.fillText(legendText, 30, 12.5);
|
||||
cx.translate(cx.measureText(legendText).width + 25 + 15, 0);
|
||||
counter++;
|
||||
}
|
||||
},
|
||||
state: {
|
||||
data: [],
|
||||
title: "Example"
|
||||
},
|
||||
onMounted() {
|
||||
let canvas = this.$("canvas");
|
||||
this.updateCanvas();
|
||||
|
@@ -1,23 +1,134 @@
|
||||
/*
|
||||
Parcoursup API (PAPI)
|
||||
Comprend un set de wrapper afin d'accéder plus aisément aux informations de l'API parcoursup
|
||||
*/
|
||||
|
||||
class PAPI {
|
||||
static dataset = "fr-esr-parcoursup";
|
||||
static timezone = "Europe%2FBerlin";
|
||||
static searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=${PAPI.dataset}&timezone=${PAPI.timezone}`;
|
||||
static async fetchFilieres() {
|
||||
if (localStorage.getItem("filis")) return JSON.parse(localStorage.getItem("filis"));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fili`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("filis", JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchFiliere(filiere) {
|
||||
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + filiere));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("fili." + filiere, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchSpecialites(filiere, specialite) {
|
||||
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
|
||||
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["records"];
|
||||
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
const SORT_TABLE = [{
|
||||
name: "Nom",
|
||||
id: "g_ea_lib_vx"
|
||||
}, {
|
||||
name: "Ville",
|
||||
id: "ville_etab"
|
||||
}, {
|
||||
name: "Département",
|
||||
id: "dep"
|
||||
}, {
|
||||
name: "Moyenne",
|
||||
id: "moyenne"
|
||||
}, {
|
||||
name: "Sélectivité",
|
||||
id: "taux_acces_ens"
|
||||
}];
|
||||
var mainController = {
|
||||
css: null,
|
||||
exports: {
|
||||
onBeforeMount(props, state) {
|
||||
//Initial state
|
||||
this.state = {
|
||||
course: null,
|
||||
updating: false,
|
||||
shouldShowInfos: false
|
||||
};
|
||||
sortList(sortBy) {
|
||||
//Si la liste est déjà triée par la bonne catégorie, on l'inverse
|
||||
if (sortBy == this.state.sortBy) {
|
||||
this.state.schoolList.reverse();
|
||||
}
|
||||
//Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut)
|
||||
else {
|
||||
this.state.sortBy = sortBy;
|
||||
switch (sortBy) {
|
||||
case SORT_TABLE[3].id:
|
||||
case SORT_TABLE[4].id:
|
||||
{
|
||||
this.state.schoolList.sort((a, b) => {
|
||||
if (a.fields[sortBy] > b.fields[sortBy]) return 1;else return -1;
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
this.state.schoolList.sort((a, b) => {
|
||||
return a.fields[sortBy].localeCompare(b.fields[sortBy]);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.update({
|
||||
schoolList: this.state.schoolList
|
||||
});
|
||||
},
|
||||
updateList(course) {
|
||||
course = course || this.state.course;
|
||||
PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then(response => {
|
||||
response.forEach(etablissement => {
|
||||
// calcul la moyenne
|
||||
let pct_sansmention = etablissement.fields.pct_sansmention;
|
||||
let pct_AB = etablissement.fields.pct_ab;
|
||||
let pct_B = etablissement.fields.pct_b;
|
||||
let pct_TB = etablissement.fields.pct_tb;
|
||||
let pct_TBF = etablissement.fields.pct_tbf;
|
||||
|
||||
// On prend la moyenne des moyennes comprises dans la mention
|
||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||
etablissement.fields.moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
|
||||
});
|
||||
this.update({
|
||||
schoolList: response
|
||||
});
|
||||
});
|
||||
},
|
||||
updateCourse(course) {
|
||||
this.updateList(course);
|
||||
this.update({
|
||||
course: course,
|
||||
shouldShowInfos: course != null,
|
||||
updating: !this.state.updating
|
||||
sortFields: SORT_TABLE,
|
||||
shouldShowInfos: course != null
|
||||
});
|
||||
},
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
course: null,
|
||||
sortBy: null,
|
||||
schoolList: null,
|
||||
sortFields: SORT_TABLE,
|
||||
shouldShowInfos: false
|
||||
});
|
||||
}
|
||||
},
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr125="expr125"></search></div><div class="column"><fili-info expr126="expr126"></fili-info><school expr127="expr127"></school></div></div><school-info expr128="expr128"></school-info>', [{
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr0="expr0"></search></div><div class="column"><fili-info expr1="expr1"></fili-info><school expr2="expr2"></school></div></div><school-info expr3="expr3"></school-info>', [{
|
||||
type: bindingTypes.TAG,
|
||||
getComponent: getComponent,
|
||||
evaluate: _scope => 'search',
|
||||
@@ -27,14 +138,18 @@ var mainController = {
|
||||
name: 'updateCourse',
|
||||
evaluate: _scope => _scope.updateCourse
|
||||
}],
|
||||
redundantAttribute: 'expr125',
|
||||
selector: '[expr125]'
|
||||
redundantAttribute: 'expr0',
|
||||
selector: '[expr0]'
|
||||
}, {
|
||||
type: bindingTypes.TAG,
|
||||
getComponent: getComponent,
|
||||
evaluate: _scope => 'fili-info',
|
||||
slots: [],
|
||||
attributes: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'schoolList',
|
||||
evaluate: _scope => _scope.state.schoolList
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'course',
|
||||
evaluate: _scope => _scope.state.course
|
||||
@@ -43,8 +158,8 @@ var mainController = {
|
||||
name: 'shouldShowInfos',
|
||||
evaluate: _scope => _scope.state.shouldShowInfos
|
||||
}],
|
||||
redundantAttribute: 'expr126',
|
||||
selector: '[expr126]'
|
||||
redundantAttribute: 'expr1',
|
||||
selector: '[expr1]'
|
||||
}, {
|
||||
type: bindingTypes.TAG,
|
||||
getComponent: getComponent,
|
||||
@@ -52,8 +167,16 @@ var mainController = {
|
||||
slots: [],
|
||||
attributes: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'parentUpdate',
|
||||
evaluate: _scope => _scope.state.updating
|
||||
name: 'sortList',
|
||||
evaluate: _scope => _scope.sortList
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'schoolList',
|
||||
evaluate: _scope => _scope.state.schoolList
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'sortFields',
|
||||
evaluate: _scope => _scope.state.sortFields
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'course',
|
||||
@@ -63,16 +186,16 @@ var mainController = {
|
||||
name: 'shouldShowInfos',
|
||||
evaluate: _scope => _scope.state.shouldShowInfos
|
||||
}],
|
||||
redundantAttribute: 'expr127',
|
||||
selector: '[expr127]'
|
||||
redundantAttribute: 'expr2',
|
||||
selector: '[expr2]'
|
||||
}, {
|
||||
type: bindingTypes.TAG,
|
||||
getComponent: getComponent,
|
||||
evaluate: _scope => 'school-info',
|
||||
slots: [],
|
||||
attributes: [],
|
||||
redundantAttribute: 'expr128',
|
||||
selector: '[expr128]'
|
||||
redundantAttribute: 'expr3',
|
||||
selector: '[expr3]'
|
||||
}]),
|
||||
name: 'main-controller'
|
||||
};
|
||||
|
@@ -35,15 +35,15 @@ class PAPI {
|
||||
return response
|
||||
}
|
||||
|
||||
static async fetchSpecialites(specialite) {
|
||||
static async fetchSpecialites(filiere, specialite) {
|
||||
|
||||
if (localStorage.getItem("spe." + specialite)) return JSON.parse(localStorage.getItem("spe." + specialite))
|
||||
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`))
|
||||
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}`)
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`)
|
||||
let result = await request.json()
|
||||
let response = result["facet_groups"][0]["facets"]
|
||||
|
||||
localStorage.setItem("spe." + specialite, JSON.stringify(response))
|
||||
localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response))
|
||||
|
||||
return response
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class PAPI {
|
||||
|
||||
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`))
|
||||
|
||||
let request = await fetch(`${PAPI.searchURL}&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`)
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`)
|
||||
let result = await request.json()
|
||||
let response = result["records"]
|
||||
|
||||
|
@@ -10,14 +10,14 @@ var schoolInfo = {
|
||||
this.update();
|
||||
}
|
||||
},
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr10="expr10" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr29="expr29" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
|
||||
type: bindingTypes.IF,
|
||||
evaluate: _scope => _scope.state.enabled,
|
||||
redundantAttribute: 'expr10',
|
||||
selector: '[expr10]',
|
||||
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr11="expr11" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr12="expr12" style="height: 90px; margin: 10px;"></line-graph></div>', [{
|
||||
redundantAttribute: 'expr11',
|
||||
selector: '[expr11]',
|
||||
redundantAttribute: 'expr29',
|
||||
selector: '[expr29]',
|
||||
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr30="expr30" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr31="expr31" style="height: 90px; margin: 10px;"></line-graph></div>', [{
|
||||
redundantAttribute: 'expr30',
|
||||
selector: '[expr30]',
|
||||
expressions: [{
|
||||
type: expressionTypes.EVENT,
|
||||
name: 'onclick',
|
||||
@@ -29,8 +29,8 @@ var schoolInfo = {
|
||||
evaluate: _scope => 'line-graph',
|
||||
slots: [],
|
||||
attributes: [],
|
||||
redundantAttribute: 'expr12',
|
||||
selector: '[expr12]'
|
||||
redundantAttribute: 'expr31',
|
||||
selector: '[expr31]'
|
||||
}])
|
||||
}]),
|
||||
name: 'school-info'
|
||||
|
@@ -1,150 +1,30 @@
|
||||
/*
|
||||
Parcoursup API (PAPI)
|
||||
Comprend un set de wrapper afin d'accéder plus aisément aux informations de l'API parcoursup
|
||||
*/
|
||||
|
||||
class PAPI {
|
||||
static dataset = "fr-esr-parcoursup";
|
||||
static timezone = "Europe%2FBerlin";
|
||||
static searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=${PAPI.dataset}&timezone=${PAPI.timezone}`;
|
||||
static async fetchFilieres() {
|
||||
if (localStorage.getItem("filis")) return JSON.parse(localStorage.getItem("filis"));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fili`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("filis", JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchFiliere(filiere) {
|
||||
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + filiere));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("fili." + filiere, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchSpecialites(specialite) {
|
||||
if (localStorage.getItem("spe." + specialite)) return JSON.parse(localStorage.getItem("spe." + specialite));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("spe." + specialite, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
|
||||
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`));
|
||||
let request = await fetch(`${PAPI.searchURL}&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["records"];
|
||||
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchEtablissement(course) {
|
||||
return PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili);
|
||||
}
|
||||
const SORT_TABLE = [{
|
||||
name: "Nom",
|
||||
id: "g_ea_lib_vx"
|
||||
}, {
|
||||
name: "Ville",
|
||||
id: "ville_etab"
|
||||
}, {
|
||||
name: "Département",
|
||||
id: "dep"
|
||||
}, {
|
||||
name: "Moyenne",
|
||||
id: "moyenne"
|
||||
}, {
|
||||
name: "Sélectivité",
|
||||
id: "taux_acces_ens"
|
||||
}];
|
||||
var school = {
|
||||
css: null,
|
||||
exports: function search() {
|
||||
return {
|
||||
updateList() {
|
||||
fetchEtablissement(this.props.course).then(response => {
|
||||
response.forEach(etablissement => {
|
||||
// calcul la moyenne
|
||||
let pct_sansmention = etablissement.fields.pct_sansmention;
|
||||
let pct_AB = etablissement.fields.pct_ab;
|
||||
let pct_B = etablissement.fields.pct_b;
|
||||
let pct_TB = etablissement.fields.pct_tb;
|
||||
let pct_TBF = etablissement.fields.pct_tbf;
|
||||
|
||||
// On prend la moyenne des moyennes comprises dans la mention
|
||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||
etablissement.fields.moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
|
||||
});
|
||||
this.update({
|
||||
items: response,
|
||||
parentUpdate: this.props.parentUpdate
|
||||
});
|
||||
});
|
||||
},
|
||||
sortList(sortBy) {
|
||||
//Si la liste est déjà triée par la bonne catégorie, on l'inverse
|
||||
if (sortBy == this.state.sortBy) {
|
||||
this.state.items.reverse();
|
||||
}
|
||||
//Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut)
|
||||
else {
|
||||
this.state.sortBy = sortBy;
|
||||
switch (sortBy) {
|
||||
case SORT_TABLE[3].id:
|
||||
case SORT_TABLE[4].id:
|
||||
{
|
||||
this.state.items.sort((a, b) => {
|
||||
if (a.fields[sortBy] > b.fields[sortBy]) return 1;else return -1;
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
this.state.items.sort((a, b) => {
|
||||
return a.fields[sortBy].localeCompare(b.fields[sortBy]);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.update({
|
||||
items: this.state.items
|
||||
});
|
||||
},
|
||||
onBeforeMount(props, state) {
|
||||
},
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
sortFields: SORT_TABLE
|
||||
});
|
||||
},
|
||||
onUpdated(props, state) {
|
||||
if (!props.shouldShowInfos || state.parentUpdate == props.parentUpdate) return;
|
||||
this.updateList();
|
||||
}
|
||||
};
|
||||
},
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr336="expr336" class="box p-2 m-2"></div>', [{
|
||||
exports: null,
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr345="expr345" class="box p-2 m-2" disabled></div>', [{
|
||||
type: bindingTypes.IF,
|
||||
evaluate: _scope => _scope.props.shouldShowInfos,
|
||||
redundantAttribute: 'expr336',
|
||||
selector: '[expr336]',
|
||||
template: template('<iframe 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&layer=mapnik" style="border-radius: 5px;"></iframe><br/><div class="block control has-icons-left is-inline-block is-pulled-right"><input class="input" 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"><thead><tr><th expr337="expr337"></th></tr></thead><tbody><tr expr339="expr339"></tr></tbody></table>', [{
|
||||
redundantAttribute: 'expr345',
|
||||
selector: '[expr345]',
|
||||
template: template('<iframe expr346="expr346" 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&layer=mapnik" style="border-radius: 5px;"></iframe><br/><div class="block control has-icons-left is-inline-block is-pulled-right"><input class="input" 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"><thead><tr><th expr347="expr347"></th></tr></thead><tbody><tr expr349="expr349"></tr></tbody></table>', [{
|
||||
type: bindingTypes.IF,
|
||||
evaluate: _scope => false,
|
||||
redundantAttribute: 'expr346',
|
||||
selector: '[expr346]',
|
||||
template: template(null, [])
|
||||
}, {
|
||||
type: bindingTypes.EACH,
|
||||
getKey: null,
|
||||
condition: null,
|
||||
template: template(' <a expr338="expr338"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{
|
||||
template: template(' <a expr348="expr348"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => [_scope.sortField.name].join('')
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr338',
|
||||
selector: '[expr338]',
|
||||
redundantAttribute: 'expr348',
|
||||
selector: '[expr348]',
|
||||
expressions: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'id',
|
||||
@@ -152,64 +32,68 @@ var school = {
|
||||
}, {
|
||||
type: expressionTypes.EVENT,
|
||||
name: 'onclick',
|
||||
evaluate: _scope => () => _scope.sortList(_scope.sortField.id)
|
||||
evaluate: _scope => () => _scope.props.sortList(_scope.sortField.id)
|
||||
}]
|
||||
}]),
|
||||
redundantAttribute: 'expr337',
|
||||
selector: '[expr337]',
|
||||
redundantAttribute: 'expr347',
|
||||
selector: '[expr347]',
|
||||
itemName: 'sortField',
|
||||
indexName: null,
|
||||
evaluate: _scope => _scope.state.sortFields
|
||||
evaluate: _scope => _scope.props.sortFields
|
||||
}, {
|
||||
type: bindingTypes.EACH,
|
||||
getKey: null,
|
||||
condition: null,
|
||||
template: template('<td expr340="expr340"> </td><td expr341="expr341"> </td><td expr342="expr342"> </td><td expr343="expr343"> </td><td expr344="expr344"> </td>', [{
|
||||
redundantAttribute: 'expr340',
|
||||
selector: '[expr340]',
|
||||
template: template('<td expr350="expr350"> </td><td expr351="expr351"> </td><td expr352="expr352"> </td><td expr353="expr353"> </td><td><title-progress expr354="expr354" max="100" style="margin: auto"></title-progress></td>', [{
|
||||
redundantAttribute: 'expr350',
|
||||
selector: '[expr350]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.etablissement.fields.g_ea_lib_vx
|
||||
evaluate: _scope => _scope.school.fields.g_ea_lib_vx
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr341',
|
||||
selector: '[expr341]',
|
||||
redundantAttribute: 'expr351',
|
||||
selector: '[expr351]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.etablissement.fields.ville_etab
|
||||
evaluate: _scope => _scope.school.fields.ville_etab
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr342',
|
||||
selector: '[expr342]',
|
||||
redundantAttribute: 'expr352',
|
||||
selector: '[expr352]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.etablissement.fields.dep
|
||||
evaluate: _scope => _scope.school.fields.dep
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr343',
|
||||
selector: '[expr343]',
|
||||
redundantAttribute: 'expr353',
|
||||
selector: '[expr353]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.etablissement.fields.moyenne
|
||||
evaluate: _scope => _scope.school.fields.moyenne
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr344',
|
||||
selector: '[expr344]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.etablissement.fields.taux_acces_ens
|
||||
}]
|
||||
type: bindingTypes.TAG,
|
||||
getComponent: getComponent,
|
||||
evaluate: _scope => 'title-progress',
|
||||
slots: [],
|
||||
attributes: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'value',
|
||||
evaluate: _scope => _scope.school.fields.taux_acces_ens
|
||||
}],
|
||||
redundantAttribute: 'expr354',
|
||||
selector: '[expr354]'
|
||||
}]),
|
||||
redundantAttribute: 'expr339',
|
||||
selector: '[expr339]',
|
||||
itemName: 'etablissement',
|
||||
redundantAttribute: 'expr349',
|
||||
selector: '[expr349]',
|
||||
itemName: 'school',
|
||||
indexName: null,
|
||||
evaluate: _scope => _scope.state.items
|
||||
evaluate: _scope => _scope.props.schoolList
|
||||
}])
|
||||
}]),
|
||||
name: 'school'
|
||||
|
@@ -23,17 +23,17 @@ class PAPI {
|
||||
localStorage.setItem("fili." + filiere, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchSpecialites(specialite) {
|
||||
if (localStorage.getItem("spe." + specialite)) return JSON.parse(localStorage.getItem("spe." + specialite));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}`);
|
||||
static async fetchSpecialites(filiere, specialite) {
|
||||
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`));
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["facet_groups"][0]["facets"];
|
||||
localStorage.setItem("spe." + specialite, JSON.stringify(response));
|
||||
localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response));
|
||||
return response;
|
||||
}
|
||||
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
|
||||
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`));
|
||||
let request = await fetch(`${PAPI.searchURL}&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
|
||||
let request = await fetch(`${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
|
||||
let result = await request.json();
|
||||
let response = result["records"];
|
||||
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
|
||||
@@ -55,7 +55,7 @@ var search = {
|
||||
promise = PAPI.fetchFiliere(this.state.course.fili);
|
||||
break;
|
||||
case 2:
|
||||
promise = PAPI.fetchSpecialites(this.state.course.sousfili);
|
||||
promise = PAPI.fetchSpecialites(this.state.course.fili, this.state.course.sousfili);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@@ -144,9 +144,9 @@ var search = {
|
||||
this.updateList();
|
||||
}
|
||||
},
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr27="expr27" class="input" type="input"/><button expr28="expr28" class="button ml-1"><</button></div><div id="list-formations"><ul><li expr29="expr29" class="m-1"></li></ul></div></div>', [{
|
||||
redundantAttribute: 'expr27',
|
||||
selector: '[expr27]',
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr23="expr23" class="input" type="input"/><button expr24="expr24" class="button ml-1"><</button></div><div id="list-formations"><ul><li expr25="expr25" class="m-1"></li></ul></div></div>', [{
|
||||
redundantAttribute: 'expr23',
|
||||
selector: '[expr23]',
|
||||
expressions: [{
|
||||
type: expressionTypes.EVENT,
|
||||
name: 'onkeyup',
|
||||
@@ -157,8 +157,8 @@ var search = {
|
||||
evaluate: _scope => _scope.state.placeholder
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr28',
|
||||
selector: '[expr28]',
|
||||
redundantAttribute: 'expr24',
|
||||
selector: '[expr24]',
|
||||
expressions: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'disabled',
|
||||
@@ -172,9 +172,9 @@ var search = {
|
||||
type: bindingTypes.EACH,
|
||||
getKey: null,
|
||||
condition: null,
|
||||
template: template('<button expr30="expr30" class="button is-fullwidth p-2"><span style="font-size: .75em; max-size: 90%"><strong expr31="expr31"> </strong></span><div style="margin-left: auto;"></div><span expr32="expr32" class="tag is-primary"> </span></button>', [{
|
||||
redundantAttribute: 'expr30',
|
||||
selector: '[expr30]',
|
||||
template: template('<button expr26="expr26" class="button is-fullwidth p-2"><span style="font-size: .75em; max-size: 90%"><strong expr27="expr27"> </strong></span><div style="margin-left: auto;"></div><span expr28="expr28" class="tag is-primary"> </span></button>', [{
|
||||
redundantAttribute: 'expr26',
|
||||
selector: '[expr26]',
|
||||
expressions: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'disabled',
|
||||
@@ -185,24 +185,24 @@ var search = {
|
||||
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr31',
|
||||
selector: '[expr31]',
|
||||
redundantAttribute: 'expr27',
|
||||
selector: '[expr27]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.item.name
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr32',
|
||||
selector: '[expr32]',
|
||||
redundantAttribute: 'expr28',
|
||||
selector: '[expr28]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.item.count
|
||||
}]
|
||||
}]),
|
||||
redundantAttribute: 'expr29',
|
||||
selector: '[expr29]',
|
||||
redundantAttribute: 'expr25',
|
||||
selector: '[expr25]',
|
||||
itemName: 'item',
|
||||
indexName: null,
|
||||
evaluate: _scope => _scope.state.items
|
||||
|
68
javascript/title-progress.js
Normal file
68
javascript/title-progress.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto";
|
||||
const COLOR_CLASSES = ["is-link", "is-info", "is-success", "is-warning", "is-danger"];
|
||||
var titleProgress = {
|
||||
css: null,
|
||||
exports: {
|
||||
computeClasses() {
|
||||
if (!this.props.value) return DEFAULT_CLASSES;
|
||||
let n = Math.floor(this.props.value / 20);
|
||||
if (n == 5) n = 4;
|
||||
return DEFAULT_CLASSES + " " + COLOR_CLASSES[n];
|
||||
},
|
||||
calcPct() {
|
||||
if (!this.props.value) {
|
||||
return "???";
|
||||
} else {
|
||||
return Math.round(this.props.value / this.props.max * 100) + "%";
|
||||
}
|
||||
},
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
class: this.computeClasses()
|
||||
});
|
||||
},
|
||||
onBeforeUpdate(props, state) {
|
||||
state.class = this.computeClasses();
|
||||
}
|
||||
},
|
||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div style="display: flex;"><span expr493="expr493"></span><span expr494="expr494" class="ml-1"> </span><progress expr495="expr495" style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress></div>', [{
|
||||
type: bindingTypes.IF,
|
||||
evaluate: _scope => _scope.props.title,
|
||||
redundantAttribute: 'expr493',
|
||||
selector: '[expr493]',
|
||||
template: template(' ', [{
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.props.title
|
||||
}]
|
||||
}])
|
||||
}, {
|
||||
redundantAttribute: 'expr494',
|
||||
selector: '[expr494]',
|
||||
expressions: [{
|
||||
type: expressionTypes.TEXT,
|
||||
childNodeIndex: 0,
|
||||
evaluate: _scope => _scope.calcPct()
|
||||
}]
|
||||
}, {
|
||||
redundantAttribute: 'expr495',
|
||||
selector: '[expr495]',
|
||||
expressions: [{
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'value',
|
||||
evaluate: _scope => _scope.props.value
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'max',
|
||||
evaluate: _scope => _scope.props.max
|
||||
}, {
|
||||
type: expressionTypes.ATTRIBUTE,
|
||||
name: 'class',
|
||||
evaluate: _scope => _scope.state.class
|
||||
}]
|
||||
}]),
|
||||
name: 'title-progress'
|
||||
};
|
||||
|
||||
export { titleProgress as default };
|
Reference in New Issue
Block a user