This commit is contained in:
2023-03-26 17:41:29 +02:00
6 changed files with 100 additions and 123 deletions

View File

@@ -1,33 +1,50 @@
<search>
<label>
<input oninput={search} type="input" placeholder= {state.formation}>
<p class="error"></p>
<input oninput={searchF} type="input" placeholder= {state.formation}>
<div id="list-formations">
<ul>
<li each={item in this.state.items}>
<a href={item.path} target="_blank">{item.name}</a>
<span>{item.count}</span>
</li>
</ul>
</div>
</label>
<script>
import model from '../javascript/modelSearch.js';
import Controller from '../javascript/controllerSearch.js';
import View from '../javascript/viewSearch.js';
async function formation(){
let result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin")
let resultats = await result.json()
let table = resultats["facet_groups"][0]["facets"]
return table
}
export default function search(){
return {
onBeforeMount(props, state) {
// initial state
this.state = {
formation: props.formation
}
},
search(){
console.log("test1")
const view = new View()
const app = new Controller(view,model)
return {
onBeforeMount(props, state) {
// initial state
this.state = {
formation: props.formation,
items: null
}
formation().then((response) => {
this.update({
items: response
})
})
console.log(this.state.items)
},
searchF(){
formation().then((response) => {
this.update({
items: response
})
})
console.log(this.state.items)
}
}
}
</script>
</search>

View File

@@ -0,0 +1,52 @@
<formation>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<table class="table is-fullwidth is-hoverable">
<tbody1>
<tr >
<th></th>
<th></th>
</tr>
</tbody1>
</table>
<script>
async function formation (){
let result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin")
let resultats = await result.json()
console.log(result)
console.log(resultats)
let base=[]
let filieretable=[]
let filieredetail=[]
let table = resultats["facet_groups"][0]["facets"]
console.log(table)
const tableBody = document.querySelector("tbody1")
for(tes of table){
const tableRow = document.createElement("tr")
const formationCell = document.createElement("td")
let texteformation = document.createTextNode(tes.name)
formationCell.appendChild(texteformation)
tableRow.appendChild(formationCell)
const nombredeplaceCell = document.createElement("td")
const nombredeplace = document.createTextNode(tes.count)
nombredeplaceCell.appendChild(nombredeplace)
tableRow.appendChild(nombredeplaceCell)
tableBody.appendChild(tableRow)
}
}
export default{
onMounted(){
formation()
}
}
</script>
</formation>