This commit is contained in:
arussac
2025-02-11 11:23:33 +01:00
parent ec6d1c1854
commit 3b694ff751
3 changed files with 47 additions and 39 deletions

View File

@@ -6,7 +6,6 @@ document.addEventListener("DOMContentLoaded", async () => {
const DataMetrics = await getDataMetrics(projectId); const DataMetrics = await getDataMetrics(projectId);
document.getElementById("name_project").innerHTML = data[projectId].name; document.getElementById("name_project").innerHTML = data[projectId].name;
const videoSelector = document.getElementById("video_selector"); const videoSelector = document.getElementById("video_selector");
const numberPicker = document.getElementById('number-picker'); const numberPicker = document.getElementById('number-picker');
const resultContainer = document.getElementById('result-container'); const resultContainer = document.getElementById('result-container');
@@ -16,7 +15,6 @@ document.addEventListener("DOMContentLoaded", async () => {
const addNumberButton = document.getElementById('add-number-button'); const addNumberButton = document.getElementById('add-number-button');
const formContainer = document.getElementById('form-container'); const formContainer = document.getElementById('form-container');
const durationInput = document.getElementById('duration'); const durationInput = document.getElementById('duration');
const tableBody = document.getElementById("imageSource");
const tableImage = document.getElementById("content1"); const tableImage = document.getElementById("content1");
const numberBoard = document.getElementById('number-board'); const numberBoard = document.getElementById('number-board');
@@ -142,25 +140,6 @@ document.addEventListener("DOMContentLoaded", async () => {
} }
} }
function populateImageTable(DataMetrics) {
let row = document.createElement("tr");
let i = 0;
DataMetrics.forEach((measure) => {
let imageTD = document.createElement("td");
imageTD.innerHTML = `<img id="${i}" src="${measure.image_path}" />`;
row.appendChild(imageTD);
if ((i + 1) % 3 === 0 && i !== 0) {
tableBody.appendChild(row);
row = document.createElement("tr");
}
if (row.childNodes.length > 0) {
tableBody.appendChild(row);
}
i++;
});
}
function populateNumberBoard(length) { function populateNumberBoard(length) {
numberBoard.innerHTML = ''; numberBoard.innerHTML = '';
for (let i = 1; i <= length; i++) { for (let i = 1; i <= length; i++) {
@@ -171,12 +150,34 @@ document.addEventListener("DOMContentLoaded", async () => {
numberBoard.appendChild(numberButton); numberBoard.appendChild(numberButton);
} }
} }
function highlightNumber(button) { function highlightNumber(button) {
button.classList.toggle('highlight'); button.classList.toggle('highlight');
} }
}); });
function populateImageTable(DataMetrics) {
const tableBody = document.getElementById("imageSource");
while (tableBody.rows.length > 0) {
tableBody.deleteRow(0);
}
let row = document.createElement("tr");
let i = 0;
DataMetrics.forEach((measure) => {
let imageTD = document.createElement("td");
imageTD.innerHTML = `<img id="${i}" src="${api_url}/image/${measure.image_path}"/>`;
row.appendChild(imageTD);
if ((i + 1) % 3 === 0 && i !== 0) {
tableBody.appendChild(row);
row = document.createElement("tr");
}
if (row.childNodes.length > 0) {
tableBody.appendChild(row);
}
i++;
});
}
async function generateViewMetric(projectId) { async function generateViewMetric(projectId) {
const ctx = document.getElementById("metric_viewer").getContext("2d"); const ctx = document.getElementById("metric_viewer").getContext("2d");
let Hygrometrie = []; let Hygrometrie = [];
@@ -196,17 +197,22 @@ async function generateViewMetric(projectId) {
}); });
const videoId = document.getElementById("video_selector").value; const videoId = document.getElementById("video_selector").value;
measurements = await getDataMetrics(projectId); measurements = await getDataMetrics(projectId);
currentVideoDatas = await getDataVideoFromApi(videoId); let samples;
if(videoId!=-1){
let samples = convertStringToArray(currentVideoDatas[0]["measurement_ids"]); currentVideoDatas = await getDataVideoFromApi(videoId);
samples = convertStringToArray(currentVideoDatas[0]["measurement_ids"]);
} else {
samples=measurements.map(measurements => measurements.id);
}
tempoMeasure = filterAndSortMeasurementsByIds(measurements, samples); tempoMeasure = filterAndSortMeasurementsByIds(measurements, samples);
tempoMeasure.forEach((measure) => { tempoMeasure.forEach((measure) => {
datesMeasurement.push(measure.timestamp); datesMeasurement.push(measure.timestamp);
Temperature.push(measure.temperature); Temperature.push(measure.temperature);
Hygrometrie.push(measure.humidity); Hygrometrie.push(measure.humidity);
}); });
populateImageTable(tempoMeasure)
if (myChart) { if (myChart) {
myChart.destroy(); myChart.destroy();

View File

@@ -1,14 +1,16 @@
async function PopulateSelect(mySelect,id){ async function PopulateSelect(mySelect, id) {
let data=[] let data = [];
if(mySelect.name=="videos" && id!=null){ if (mySelect.name == "videos" && id != null) {
data=await getDataProjectVideosFromApi(id); data = await getDataProjectVideosFromApi(id);
for(let i = 0 ; i < data.length ; i++){ const selectObjDefault = document.createElement("option");
const selectObj=document.createElement("option") selectObjDefault.value = -1;
selectObj.value=data[i].id selectObjDefault.innerHTML = "Default";
selectObj.innerHTML=data[i].name mySelect.appendChild(selectObjDefault);
mySelect.appendChild(selectObj) 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);
} }
}
} }

View File

@@ -32,7 +32,7 @@ function getAllProject() {
function getDataMetrics(projectId){ function getDataMetrics(projectId){
return $.ajax({ return $.ajax({
url: api_url.concat("/projects/"+projectId+"/measurements"), url: api_url.concat(`/projects/${projectId}/measurements`),
method: "GET", method: "GET",
dataType: "json", dataType: "json",
}).then((data) => { }).then((data) => {