added possibility to filter datas
This commit is contained in:
parent
98d8cc7bfd
commit
edb214c459
19
model.js
19
model.js
@ -1,19 +0,0 @@
|
|||||||
function execQuery(table, filter = "all", id = -1){
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
};
|
|
25
onzer.riot
25
onzer.riot
@ -65,7 +65,7 @@
|
|||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
async fetchData(){
|
async fetchData(){
|
||||||
let data = await execQuery(this.state.search, this.state.filter, this.state.id);
|
let data = await this.execQuery(this.state.search, this.state.filter, this.state.id);
|
||||||
this.update({
|
this.update({
|
||||||
items: data.results
|
items: data.results
|
||||||
});
|
});
|
||||||
@ -74,7 +74,7 @@
|
|||||||
this.album_style = "isDeactivate";
|
this.album_style = "isDeactivate";
|
||||||
this.artist_style = "isDeactivate";
|
this.artist_style = "isDeactivate";
|
||||||
this.song_style = "isDeactivate";
|
this.song_style = "isDeactivate";
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
@ -92,4 +92,25 @@
|
|||||||
width: 32%;
|
width: 32%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
function execQuery(table, filter = "all", id = -1){
|
||||||
|
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>
|
||||||
|
Loading…
Reference in New Issue
Block a user