added possibility to filter datas

This commit is contained in:
Matthis FAUVET 2024-06-21 19:38:47 +02:00
parent b97ed0c1b8
commit 85b1c63219

View File

@ -75,6 +75,25 @@
this.artist_style = "isDeactivate"; this.artist_style = "isDeactivate";
this.song_style = "isDeactivate"; this.song_style = "isDeactivate";
}, },
execQuery(table, filter = undefined, id = undefined){
let baseHttpRequest = "https://dwarves.iut-fbleau.fr/~fauvet/api/"
let computeHttpRequest;
if(filter !== undefined){
switch(table){
case "songs":
computeHttpRequest = baseHttpRequest+table+"?title="+filter;
default :
computeHttpRequest = baseHttpRequest+table+"?name="+filter;
}
} else if(id !== undefined) {
computeHttpRequest = baseHttpRequest+table+"/"+id;
} else {
computeHttpRequest = baseHttpRequest+table;
}
return fetch(computeHttpRequest).then(response => {
return response.json();
});
}
} }
</script> </script>
<style> <style>
@ -92,25 +111,4 @@
width: 32%; width: 32%;
} }
</style> </style>
<script>
function execQuery(table, filter = undefined, id = undefined){
let baseHttpRequest = "https://dwarves.iut-fbleau.fr/~fauvet/api/"
let computeHttpRequest;
if(filter !== undefined){
switch(table){
case "songs":
computeHttpRequest = baseHttpRequest+table+"?title="+filter;
default :
computeHttpRequest = baseHttpRequest+table+"?name="+filter;
}
} else if(id !== undefined) {
computeHttpRequest = baseHttpRequest+table+"/"+id;
} else {
computeHttpRequest = baseHttpRequest+table;
}
return fetch(computeHttpRequest).then(response => {
return response.json();
});
};
</script>
</onzer> </onzer>