Ajout analyse de rapports

This commit is contained in:
Jérôme Delacotte
2025-05-10 17:09:59 +02:00
parent c8fd868b6b
commit adef1736e5
5 changed files with 89 additions and 3 deletions

View File

@@ -497,10 +497,36 @@ function loadFeather(filename) {
element.value = filename
fetch(`/read_feather/${filename}`)
.then(response => response.json())
.then(data => renderChart(data, filename, true) );
.then(data => {
renderChart(data, filename, true)
initReport(data)
})
}
function initReport(data) {
string = "<ul class='indicators'>" +
Object.keys(data[0])
// .filter(key => !['date', 'open', 'close', 'volume', 'high', 'low'].includes(key))
.map(cols => `<li><label><input id="${cols}" type="checkbox" value="${cols}" onchange="toggleReportIndicator(this)">${cols}</label></li>`)
.join('') +
"</ul>"
const indicators = document.getElementById('indicatorsReport')
indicators.innerHTML = string
}
function generateReport() {
const element = document.getElementById('current_file_name');
let filename = element.value
const indicators = Array.from(selectedReportIndicators).join(',');
fetch(`/generate_report?filename=${filename}&indicators=${indicators}`)
.then(alert('Generation en cours'));
}
let selectedIndicators = new Set();
let selectedReportIndicators = new Set();
function toggleIndicator(checkbox) {
const indicator = checkbox.value;
@@ -511,6 +537,15 @@ function toggleIndicator(checkbox) {
}
loadChartWithIndicators();
}
function toggleReportIndicator(checkbox) {
const indicator = checkbox.value;
if (checkbox.checked) {
selectedReportIndicators.add(indicator);
} else {
selectedReportIndicators.delete(indicator);
}
}
function loadChartWithIndicators() {
const element = document.getElementById('current_file_name');
@@ -542,4 +577,13 @@ function init() {
document.getElementById('closeIndicatorsBtn').addEventListener('click', () => {
dialog.close();
});
const dialogReport = document.getElementById('indicatorReportDialog');
document.getElementById('openIndicatorsReportBtn').addEventListener('click', () => {
dialogReport.showModal();
});
document.getElementById('closeIndicatorsReportBtn').addEventListener('click', () => {
dialogReport.close();
});
}