This commit is contained in:
@@ -3,15 +3,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const projectId = urlParams.get("id");
|
const projectId = urlParams.get("id");
|
||||||
const data = await getAllProject();
|
const data = await getAllProject();
|
||||||
const DataMetrics = await getDataMetrics(projectId);
|
let DataMetrics;
|
||||||
|
try {
|
||||||
const project = data.find((project) => project.id == projectId);
|
DataMetrics = await getDataMetrics(projectId);
|
||||||
if (project) {
|
} catch (error) {
|
||||||
for (obj of document.getElementsByClassName("name_project"))
|
if (error.status !== 404) {
|
||||||
obj.innerHTML = project.name;
|
console.error(error);
|
||||||
} else {
|
|
||||||
console.error("Project not found");
|
|
||||||
}
|
}
|
||||||
|
DataMetrics = 404; // Assign a fallback value
|
||||||
|
}
|
||||||
|
const start_timelapse_button = document.getElementById("start-timelapse");
|
||||||
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 choiceSelect = document.getElementById("choice");
|
const choiceSelect = document.getElementById("choice");
|
||||||
@@ -28,13 +29,11 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
// Add event listeners for the "Début" and "Fin" input fields
|
// Add event listeners for the "Début" and "Fin" input fields
|
||||||
const firstInput = document.getElementById("first");
|
const firstInput = document.getElementById("first");
|
||||||
const lastInput = document.getElementById("last");
|
const lastInput = document.getElementById("last");
|
||||||
const start_timelapse_button = document.getElementById("start-timelapse");
|
|
||||||
|
|
||||||
let selectedNumbers = [];
|
let selectedNumbers = [];
|
||||||
|
|
||||||
populateTimelapseLogic(start_timelapse_button, projectId).then(() => {
|
populateTimelapseLogic(start_timelapse_button, projectId).then(() => {
|
||||||
if(document
|
if (document.getElementById("show-form-button-project") != null) {
|
||||||
.getElementById("show-form-button-project") != null){
|
|
||||||
document
|
document
|
||||||
.getElementById("show-form-button-project")
|
.getElementById("show-form-button-project")
|
||||||
.addEventListener("click", showFormCamera);
|
.addEventListener("click", showFormCamera);
|
||||||
@@ -51,9 +50,14 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
const hours = document.getElementById("hours").value;
|
const hours = document.getElementById("hours").value;
|
||||||
const minutes = document.getElementById("minutes").value;
|
const minutes = document.getElementById("minutes").value;
|
||||||
const frequency = days * 1440 + hours * 60 + minutes;
|
const frequency = days * 1440 + hours * 60 + minutes;
|
||||||
start_timelapse(projectId, frequency).then(() => {
|
if(frequency >= 3) {
|
||||||
|
const nbrimages = document.getElementById("totalImages").value;
|
||||||
|
start_timelapse(projectId, frequency, nbrimages).then(() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
alert("La fréquence doit être supérieure à 3 minutes !");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (document.getElementById("stop-camera") != null) {
|
if (document.getElementById("stop-camera") != null) {
|
||||||
@@ -66,12 +70,13 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
choiceSelect.addEventListener("change", toggleContainers);
|
|
||||||
|
|
||||||
if (addNumberButton) {
|
if (addNumberButton) {
|
||||||
addNumberButton.addEventListener("click", addSelectedNumber);
|
addNumberButton.addEventListener("click", addSelectedNumber);
|
||||||
}
|
}
|
||||||
videoSelector.addEventListener("change", () => generateViewMetric(projectId));
|
videoSelector.addEventListener("change", () =>
|
||||||
|
generateViewMetric(projectId)
|
||||||
|
);
|
||||||
document
|
document
|
||||||
.getElementById("show-form-button-camera")
|
.getElementById("show-form-button-camera")
|
||||||
.addEventListener("click", showFormProject);
|
.addEventListener("click", showFormProject);
|
||||||
@@ -85,18 +90,19 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
document
|
document
|
||||||
.getElementById("decrement-button")
|
.getElementById("decrement-button")
|
||||||
.addEventListener("click", decrementDuration);
|
.addEventListener("click", decrementDuration);
|
||||||
document.getElementById("submit").addEventListener("click", handleFormSubmit);
|
document
|
||||||
|
.getElementById("submit")
|
||||||
|
.addEventListener("click", handleFormSubmit);
|
||||||
document
|
document
|
||||||
.getElementById("projets")
|
.getElementById("projets")
|
||||||
.addEventListener("click", navigateToProjects);
|
.addEventListener("click", navigateToProjects);
|
||||||
document.getElementById("toggle-view").addEventListener("click", toggleView);
|
document
|
||||||
|
.getElementById("toggle-view")
|
||||||
|
.addEventListener("click", toggleView);
|
||||||
|
|
||||||
firstInput.addEventListener("input", updateRange);
|
firstInput.addEventListener("input", updateRange);
|
||||||
lastInput.addEventListener("input", updateRange);
|
lastInput.addEventListener("input", updateRange);
|
||||||
|
|
||||||
generateViewMetric(projectId);
|
|
||||||
PopulateSelect(videoSelector, projectId);
|
|
||||||
|
|
||||||
function toggleContainers() {
|
function toggleContainers() {
|
||||||
if (choiceSelect.value === "oneByOne") {
|
if (choiceSelect.value === "oneByOne") {
|
||||||
oneByOneContainer.style.display = "block";
|
oneByOneContainer.style.display = "block";
|
||||||
@@ -254,6 +260,31 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
firstInput.max = lastValue;
|
firstInput.max = lastValue;
|
||||||
lastInput.min = firstValue;
|
lastInput.min = firstValue;
|
||||||
}
|
}
|
||||||
|
if (DataMetrics != 404) {
|
||||||
|
const project = data.find((project) => project.id == projectId);
|
||||||
|
if (project) {
|
||||||
|
for (obj of document.getElementsByClassName("name_project"))
|
||||||
|
obj.innerHTML = project.name;
|
||||||
|
} else {
|
||||||
|
console.error("Project not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
choiceSelect.addEventListener("change", toggleContainers);
|
||||||
|
|
||||||
|
generateViewMetric(projectId);
|
||||||
|
PopulateSelect(videoSelector, projectId);
|
||||||
|
} else {
|
||||||
|
document.getElementById("metric_viewer").style.display = "none";
|
||||||
|
document.getElementById("video-container").style.display = "none";
|
||||||
|
document.getElementById("delete-placeholder").style.display = "none";
|
||||||
|
document.getElementById("content1").style.display = "none";
|
||||||
|
document.getElementById("form-container-project").style.display = "none";
|
||||||
|
document.getElementById("form-container-camera").style.display = "none";
|
||||||
|
document.getElementById("show-form-button-camera").style.display = "none";
|
||||||
|
for (el of document.querySelectorAll(".box")) {
|
||||||
|
el.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function populateImageTable(DataMetrics) {
|
function populateImageTable(DataMetrics) {
|
||||||
@@ -303,6 +334,7 @@ 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);
|
||||||
|
if (measurements != 404) {
|
||||||
let samples;
|
let samples;
|
||||||
if (videoId != -1) {
|
if (videoId != -1) {
|
||||||
currentVideoDatas = await getDataVideoFromApi(videoId);
|
currentVideoDatas = await getDataVideoFromApi(videoId);
|
||||||
@@ -370,19 +402,19 @@ async function generateViewMetric(projectId) {
|
|||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
position: "left",
|
position: "left",
|
||||||
ticks: {
|
ticks: {
|
||||||
color: 'white', // Set y-axis labels to white
|
color: "white", // Set y-axis labels to white
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
color: 'white', // Set grid line color to white
|
color: "white", // Set grid line color to white
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
x: {
|
x: {
|
||||||
ticks: {
|
ticks: {
|
||||||
color: 'white', // Set x-axis labels to white
|
color: "white", // Set x-axis labels to white
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
drawOnChartArea: true,
|
drawOnChartArea: true,
|
||||||
color: 'white', // Set grid line color to white
|
color: "white", // Set grid line color to white
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
y1: {
|
y1: {
|
||||||
@@ -392,8 +424,8 @@ async function generateViewMetric(projectId) {
|
|||||||
drawOnChartArea: false, // Only want the grid lines for one axis to show up
|
drawOnChartArea: false, // Only want the grid lines for one axis to show up
|
||||||
},
|
},
|
||||||
ticks: {
|
ticks: {
|
||||||
color: 'white', // Set y-axis labels to white
|
color: "white", // Set y-axis labels to white
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
@@ -401,10 +433,13 @@ async function generateViewMetric(projectId) {
|
|||||||
labels: {
|
labels: {
|
||||||
color: "white", // Set legend labels to white
|
color: "white", // Set legend labels to white
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
document.getElementById("metric_viewer").style.display = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function showConfirmationAlert(videoId) {
|
function showConfirmationAlert(videoId) {
|
||||||
const customAlert = document.getElementById("customAlert");
|
const customAlert = document.getElementById("customAlert");
|
||||||
@@ -516,6 +551,14 @@ function decrement(id) {
|
|||||||
updateFrequencyText();
|
updateFrequencyText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decrementImage(id) {
|
||||||
|
const input = document.getElementById(id);
|
||||||
|
if (parseInt(input.value) > 1) {
|
||||||
|
input.value = parseInt(input.value) - 1;
|
||||||
|
}
|
||||||
|
updateFrequencyText();
|
||||||
|
}
|
||||||
|
|
||||||
function updateFrequencyText() {
|
function updateFrequencyText() {
|
||||||
const days = document.getElementById("days").value;
|
const days = document.getElementById("days").value;
|
||||||
const hours = document.getElementById("hours").value;
|
const hours = document.getElementById("hours").value;
|
||||||
|
|||||||
Reference in New Issue
Block a user