search.riot refactor WIP

This commit is contained in:
HORVILLE 2023-03-29 16:50:48 +02:00
parent 0e286e3008
commit ea62bb9d3f
8 changed files with 144 additions and 169 deletions

View File

@ -1,5 +1,7 @@
<school>
<main class="container">
<div class="box p-2 m-2">
<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&amp;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">
@ -29,6 +31,7 @@
</tr>
</tbody>
</table>
</div>
<script>
@ -51,7 +54,7 @@
this.update({
items: response
})
console.log(this.state.items)
//console.log(this.state.items)
this.state.items.forEach(etablissement => {
// calcul la moyenne
let pct_sansmention = etablissement.fields.pct_sansmention
@ -60,10 +63,12 @@
let pct_TB = etablissement.fields.pct_tb
let pct_TBF = etablissement.fields.pct_tbf
let moyenne = ((pct_TBF*18)+(pct_TB*16)+(pct_B*14)+(pct_AB*12)+(pct_sansmention*10))/100
// On prend la moyenne des moyennes comprises dans la mention
// Exemple : Assez bien est entre 12 et 14 donc 13.
let moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11g))/100
etablissement.fields.moyenne=moyenne
console.log(etablissement.fields)
//console.log(etablissement.fields)
})
this.update()
})

View File

@ -1,13 +1,13 @@
<search>
<div class="box p-1 m-2">
<div class="columns m-1">
<input onkeydown={searchF} class="input" type="input" placeholder={state.placeholder}>
<button class="button ml-1" onclick={back}>&lt;</button>
<input onkeydown={filterSearch} onfocusout={filterSearch} class="input" type="input" placeholder={state.placeholder}>
<button class="button ml-1" disabled={!state.currentStep} onclick={cruiseBack}>&lt;</button>
</div>
<div id="list-formations">
<ul>
<li class="m-1" each={item in this.state.items}>
<button class="button is-fullwidth" onclick={()=>filter(item.name)}>
<button class="button is-fullwidth" onclick={()=>cruiseForward(item.name)}>
<span style="font-size: .75em;"><strong>{item.name}</strong></span>
<div style="margin-left: auto;"></div>
<span class="tag is-primary">{item.count}</span>
@ -19,23 +19,52 @@
<script>
import PAPI from '../javascript/parcoursup-link.js'
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`
function cruiseBack() {
}
function cruiseForward() {
}
function filterSearch() {
}
export default {
onBeforeMount(props, state) {
//Initial state
this.state = {
placeholder: "Formation",
currentStep: 0,
allItems: null,
filter: null,
items: null
}
PAPI.fetchFilieres().then((response) => {
this.state.allItems = response
this.update({
items: filterSearch(this.state.allItems)
})
})
}
}
/*const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`
async function fetchFiliere(state) {
if (state.sousfili){
return PAPI.fetchSpecialites(state.sousfili)
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${state.sousfili}`)
} else if (state.fili && !state.sousfili){
return PAPI.fetchFiliere(state.fili)
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${state.fili}`)
} else if (!state.fili && !state.sousfili){
return PAPI.fetchFilieres()
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`)
}
}
//let result = await request.json()
//return result["facet_groups"][0]["facets"]
}
export default function search(){
return {
@ -108,8 +137,6 @@
})
}
}
}
}*/
</script>
</search>

View File

@ -1,30 +1,30 @@
var filiInfo = {
css: null,
exports: null,
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr9="expr9" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr10="expr10" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr11="expr11" style="height: 6rem;"></line-graph></div></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr4="expr4" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr5="expr5" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr6="expr6" style="height: 6rem;"></line-graph></div></div>', [{
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'line-graph',
slots: [],
attributes: [],
redundantAttribute: 'expr9',
selector: '[expr9]'
redundantAttribute: 'expr4',
selector: '[expr4]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'line-graph',
slots: [],
attributes: [],
redundantAttribute: 'expr10',
selector: '[expr10]'
redundantAttribute: 'expr5',
selector: '[expr5]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'line-graph',
slots: [],
attributes: [],
redundantAttribute: 'expr11',
selector: '[expr11]'
redundantAttribute: 'expr6',
selector: '[expr6]'
}]),
name: 'fili-info'
};

View File

@ -1,38 +1,38 @@
var mainController = {
css: null,
exports: {},
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 expr12="expr12"></search></div><div class="column"><fili-info expr13="expr13"></fili-info><school expr14="expr14"></school></div></div><school-info expr15="expr15"></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',
slots: [],
attributes: [],
redundantAttribute: 'expr12',
selector: '[expr12]'
redundantAttribute: 'expr0',
selector: '[expr0]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'fili-info',
slots: [],
attributes: [],
redundantAttribute: 'expr13',
selector: '[expr13]'
redundantAttribute: 'expr1',
selector: '[expr1]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'school',
slots: [],
attributes: [],
redundantAttribute: 'expr14',
selector: '[expr14]'
redundantAttribute: 'expr2',
selector: '[expr2]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'school-info',
slots: [],
attributes: [],
redundantAttribute: 'expr15',
selector: '[expr15]'
redundantAttribute: 'expr3',
selector: '[expr3]'
}]),
name: 'main-controller'
};

View File

@ -10,14 +10,14 @@ var schoolInfo = {
this.update();
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr0="expr0" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr7="expr7" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.state.enabled,
redundantAttribute: 'expr0',
selector: '[expr0]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr1="expr1" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr2="expr2" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr1',
selector: '[expr1]',
redundantAttribute: 'expr7',
selector: '[expr7]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr8="expr8" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr9="expr9" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr8',
selector: '[expr8]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
@ -29,8 +29,8 @@ var schoolInfo = {
evaluate: _scope => 'line-graph',
slots: [],
attributes: [],
redundantAttribute: 'expr2',
selector: '[expr2]'
redundantAttribute: 'expr9',
selector: '[expr9]'
}])
}]),
name: 'school-info'

View File

@ -55,7 +55,10 @@ var school = {
let pct_B = etablissement.fields.pct_b;
let pct_TB = etablissement.fields.pct_tb;
let pct_TBF = etablissement.fields.pct_tbf;
let moyenne = (pct_TBF * 18 + pct_TB * 16 + pct_B * 14 + pct_AB * 12 + pct_sansmention * 10) / 100;
// On prend la moyenne des moyennes comprises dans la mention
// Exemple : Assez bien est entre 12 et 14 donc 13.
let moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
etablissement.fields.moyenne = moyenne;
console.log(etablissement.fields);
});
@ -64,53 +67,53 @@ var school = {
}
};
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<main class="container"><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><abbr title="name">Nom</abbr></th><th><abbr title="city">Ville</abbr></th><th><abbr title="dept">Dpt</abbr></th><th><abbr title="moyenne">Moyenne</abbr></th><th><abbr title="selectivite">Sélectivité</abbr></th></tr></thead><tbody><tr expr58="expr58"></tr></tbody></table></main>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-2 m-2"><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&amp;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><abbr title="name">Nom</abbr></th><th><abbr title="city">Ville</abbr></th><th><abbr title="dept">Dpt</abbr></th><th><abbr title="moyenne">Moyenne</abbr></th><th><abbr title="selectivite">Sélectivité</abbr></th></tr></thead><tbody><tr expr34="expr34"></tr></tbody></table></div>', [{
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<td expr59="expr59"> </td><td expr60="expr60"> </td><td expr61="expr61"> </td><td expr62="expr62"> </td><td expr63="expr63"> </td>', [{
redundantAttribute: 'expr59',
selector: '[expr59]',
template: template('<td expr35="expr35"> </td><td expr36="expr36"> </td><td expr37="expr37"> </td><td expr38="expr38"> </td><td expr39="expr39"> </td>', [{
redundantAttribute: 'expr35',
selector: '[expr35]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.g_ea_lib_vx
}]
}, {
redundantAttribute: 'expr60',
selector: '[expr60]',
redundantAttribute: 'expr36',
selector: '[expr36]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.ville_etab
}]
}, {
redundantAttribute: 'expr61',
selector: '[expr61]',
redundantAttribute: 'expr37',
selector: '[expr37]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.dep
}]
}, {
redundantAttribute: 'expr62',
selector: '[expr62]',
redundantAttribute: 'expr38',
selector: '[expr38]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.moyenne
}]
}, {
redundantAttribute: 'expr63',
selector: '[expr63]',
redundantAttribute: 'expr39',
selector: '[expr39]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.taux_acces_ens
}]
}]),
redundantAttribute: 'expr58',
selector: '[expr58]',
redundantAttribute: 'expr34',
selector: '[expr34]',
itemName: 'etablissement',
indexName: null,
evaluate: _scope => _scope.state.items

View File

@ -29,147 +29,86 @@ class PAPI {
}
}
async function fetchFiliere(state) {
if (state.sousfili) {
return PAPI.fetchSpecialites(state.sousfili);
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${state.sousfili}`)
} else if (state.fili && !state.sousfili) {
return PAPI.fetchFiliere(state.fili);
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${state.fili}`)
} else if (!state.fili && !state.sousfili) {
return PAPI.fetchFilieres();
//var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`)
}
//let result = await request.json()
//return result["facet_groups"][0]["facets"]
}
function filterSearch() {}
var search = {
css: null,
exports: function search() {
return {
exports: {
onBeforeMount(props, state) {
// initial state
//Initial state
this.state = {
placeholder: "Formation",
items: null,
allitems: null,
fili: null,
sousfili: null
currentStep: 0,
allItems: null,
filter: null,
items: null
};
fetchFiliere(this.state).then(response => {
PAPI.fetchFilieres().then(response => {
this.state.allItems = response;
this.update({
items: response,
allitems: response
});
});
},
searchF(e) {
let responseFiltered = [];
this.state.allitems.forEach(formation => {
if (formation.name.toUpperCase().includes(e.target.value.toUpperCase())) {
responseFiltered.push(formation);
}
});
this.update({
items: responseFiltered
});
},
filter(fili) {
console.log("filter! " + fili);
if (this.state.placeholder === "Filière de formation") {
this.update({
placeholder: "Filière de formation détaillée",
sousfili: fili
});
} else if (this.state.placeholder = "Formation") {
this.update({
placeholder: "Filière de formation",
fili: fili
});
}
fetchFiliere(this.state).then(response => {
this.update({
allitems: response,
items: response
});
console.log(this.state.items);
});
},
back() {
console.log("back");
if (this.state.placeholder === "Filière de formation") {
this.update({
placeholder: "Formation",
fili: null
});
} else if (this.state.placeholder = "Filière de formation détaillée") {
this.update({
placeholder: "Filière de formation",
sousfili: null
});
}
fetchFiliere(this.state).then(response => {
this.update({
allitems: response,
items: response
items: filterSearch(this.state.allItems)
});
});
}
};
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr16="expr16" class="input" type="input"/><button expr17="expr17" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr18="expr18" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr16',
selector: '[expr16]',
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr10="expr10" class="input" type="input"/><button expr11="expr11" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr12="expr12" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr10',
selector: '[expr10]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onkeydown',
evaluate: _scope => _scope.searchF
evaluate: _scope => _scope.filterSearch
}, {
type: expressionTypes.EVENT,
name: 'onfocusout',
evaluate: _scope => _scope.filterSearch
}, {
type: expressionTypes.ATTRIBUTE,
name: 'placeholder',
evaluate: _scope => _scope.state.placeholder
}]
}, {
redundantAttribute: 'expr17',
selector: '[expr17]',
redundantAttribute: 'expr11',
selector: '[expr11]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'disabled',
evaluate: _scope => !_scope.state.currentStep
}, {
type: expressionTypes.EVENT,
name: 'onclick',
evaluate: _scope => _scope.back
evaluate: _scope => _scope.cruiseBack
}]
}, {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<button expr19="expr19" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr20="expr20"> </strong></span><div style="margin-left: auto;"></div><span expr21="expr21" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr19',
selector: '[expr19]',
template: template('<button expr13="expr13" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr14="expr14"> </strong></span><div style="margin-left: auto;"></div><span expr15="expr15" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr13',
selector: '[expr13]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
evaluate: _scope => () => _scope.filter(_scope.item.name)
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
}]
}, {
redundantAttribute: 'expr20',
selector: '[expr20]',
redundantAttribute: 'expr14',
selector: '[expr14]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.name
}]
}, {
redundantAttribute: 'expr21',
selector: '[expr21]',
redundantAttribute: 'expr15',
selector: '[expr15]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.count
}]
}]),
redundantAttribute: 'expr18',
selector: '[expr18]',
redundantAttribute: 'expr12',
selector: '[expr12]',
itemName: 'item',
indexName: null,
evaluate: _scope => _scope.state.items

View File

@ -1,6 +1,7 @@
body, html {
width: 100%;
height: 100%;
width: 100vw;
height: 100vh;
min-height: 100vh;
top: 0px;
left: 0px;
background-color: #EFEFEF;