This commit is contained in:
pro.boooooo 2023-03-12 01:04:17 +01:00
parent 57f9893c2e
commit 5f18a9fcbd
2 changed files with 25 additions and 21 deletions

View File

@ -116,7 +116,7 @@ export default class Model {
getModelData0() { getModelData0() {
if(!localStorage.getItem(`sec0`)) { if(!localStorage.getItem(`sec0`)) {
const link = `${ this.state.api.link }&rows=0` + const link = `${ this.state.api.link }&rows=0` +
`&facet=${this.state.api.facet.filiaire}` `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}`
return fetch(link) return fetch(link)
.then((res) => res.json()) .then((res) => res.json())
@ -142,10 +142,10 @@ export default class Model {
getModelData1() { getModelData1() {
if(!localStorage.getItem(`sec1-${this.state.page.cat}`)) { if(!localStorage.getItem(`sec1-${this.state.page.cat}`)) {
const link = `${this.state.api.link}&rows=0` + const link = `${this.state.api.link}&rows=0` +
`&facet=${this.state.api.facet.filiaire}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` +
`&facet=${this.state.api.facet.formation}` + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` +
`&facet=${this.state.api.facet.spec}` + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` +
`&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}`
return fetch(link) return fetch(link)
.then((res) => res.json()) .then((res) => res.json())
@ -172,11 +172,13 @@ export default class Model {
getModelData2() { getModelData2() {
if(!localStorage.getItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`)) { if(!localStorage.getItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`)) {
const link = `${this.state.api.link}&rows=0` + const link = `${this.state.api.link}&rows=0` +
`&facet=${this.state.api.facet.filiaire}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` +
`&facet=${this.state.api.facet.formation}` + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` +
`&facet=${this.state.api.facet.spec}` + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` +
`&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` + `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}` +
`&refine.${this.state.api.facet.formation}=${this.state.page.scat}` `&refine.${encodeURIComponent(this.state.api.facet.formation)}=${encodeURIComponent(this.state.page.scat)}`
console.log(link)
return fetch(link) return fetch(link)
.then((res) => res.json()) .then((res) => res.json())
@ -202,13 +204,12 @@ export default class Model {
getModelData3() { getModelData3() {
if(!localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)) { if(!localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)) {
const link = `${this.state.api.link}&rows=10000` + const link = `${this.state.api.link}&rows=10000` +
`&facet=${this.state.api.facet.filiaire}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` +
`&facet=${this.state.api.facet.formation}` + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` +
`&facet=${this.state.api.facet.spec}` + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` +
`&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` + `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}` +
`&refine.${this.state.api.facet.formation}=${this.state.page.scat}` + `&refine.${encodeURIComponent(this.state.api.facet.formation)}=${encodeURIComponent(this.state.page.scat)}` +
`&refine.${this.state.api.facet.spec}=${this.state.page.tcat}` `&refine.${encodeURIComponent(this.state.api.facet.spec)}=${encodeURIComponent(this.state.page.tcat)}`
console.log(link)
return fetch(link) return fetch(link)
.then((res) => { .then((res) => {
@ -217,7 +218,10 @@ export default class Model {
.then((data) => { .then((data) => {
try { try {
if(data) { if(data) {
localStorage.setItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`, JSON.stringify(data.records)) if(this.state.page.tcat) {
localStorage.setItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`, JSON.stringify(data.records))
}
this.state.page.tcat = null this.state.page.tcat = null
return data.records return data.records
} }

View File

@ -9,6 +9,7 @@ export default class View {
this.stat = document.getElementById("generalytics") this.stat = document.getElementById("generalytics")
this.etab = document.getElementById("etablanalytics-list") this.etab = document.getElementById("etablanalytics-list")
this.btn = document.getElementById("selector-top-btn") this.btn = document.getElementById("selector-top-btn")
this.btn.onclick = () => { this.btn.onclick = () => {
this.updateMenu(" ", "previous") this.updateMenu(" ", "previous")
} }
@ -28,8 +29,8 @@ export default class View {
if(title || data) { if(title || data) {
data.forEach((e) => { data.forEach((e) => {
let elem = document.createElement("selectorfragment") let elem = document.createElement("selectorfragment")
elem.onclick = () => { elem.onclick = async () => {
this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next") await this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next")
} }
riot.mount(elem, { riot.mount(elem, {
@ -242,7 +243,6 @@ export default class View {
b += e.fields.acc_b b += e.fields.acc_b
tb += e.fields.acc_tb tb += e.fields.acc_tb
tbf += e.fields.acc_tbf tbf += e.fields.acc_tbf
console.log(e.fields.lien_form_sup)
}) })
let tot = p + ab + b + tb + tbf let tot = p + ab + b + tb + tbf