maj
This commit is contained in:
1
js/utilities/constVariables.js
Normal file
1
js/utilities/constVariables.js
Normal file
@@ -0,0 +1 @@
|
||||
const api_url = "https://timelapse.kerboul.me/api";
|
||||
29
js/utilities/populate.js
Normal file
29
js/utilities/populate.js
Normal file
@@ -0,0 +1,29 @@
|
||||
async function PopulateSelect(mySelect,id){
|
||||
let data=[]
|
||||
if(mySelect.name=="metriques" && id!=null){
|
||||
data=await getDataProjectVideosFromApi(id);
|
||||
for(let i = 0 ; i < data.length ; i++){
|
||||
const selectObj=document.createElement("option")
|
||||
selectObj.value=data[i].id
|
||||
selectObj.innerHTML=data[i].name
|
||||
mySelect.appendChild(selectObj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getDataProjectVideosFromApi(id) {
|
||||
try {
|
||||
const response = await $.ajax({
|
||||
url: api_url.concat(`/projects/${id}/videos`),
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
});
|
||||
// If the request is successful, store the data in the cache and return it
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
throw error; // Re-throw the error to handle it outside the function if needed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user