pequeños cambios para que el step 1 sea mas robusto

This commit is contained in:
dam
2026-03-03 08:55:43 +01:00
parent 8259e85b68
commit 9a59879988
7 changed files with 184 additions and 79 deletions

View File

@@ -15,6 +15,7 @@ let downloadPollTimer = null;
async function inspectCalibrationData() {
console.log("[calibration_data] inspectCalibrationData() START ✅");
const mode = document.getElementById("market_mode")?.value || "crypto";
const symbol = document.getElementById("symbol")?.value;
const timeframe = document.getElementById("timeframe")?.value;
const start_date = document.getElementById("start_date")?.value || null;
@@ -22,7 +23,7 @@ async function inspectCalibrationData() {
const resultEl = document.getElementById("inspect-output");
const payload = { symbol, timeframe };
const payload = { symbol, timeframe, mode };
if (start_date) payload.start_date = start_date;
if (end_date) payload.end_date = end_date;
@@ -57,8 +58,11 @@ async function inspectCalibrationData() {
const dqStatus = data.data_quality?.status ?? "ok";
if (data.valid && dqStatus !== "fail") {
enableNextStep();
localStorage.setItem("calibration.mode", mode);
localStorage.setItem("calibration.symbol", data.symbol);
localStorage.setItem("calibration.timeframe", data.timeframe);
localStorage.setItem("calibration.start_date", start_date || "");
localStorage.setItem("calibration.end_date", end_date || "");
}
} catch (err) {
@@ -77,17 +81,25 @@ async function inspectCalibrationData() {
async function startDownloadJob() {
console.log("[calibration_data] startDownloadJob()");
const mode = document.getElementById("market_mode")?.value || "crypto";
const symbol = document.getElementById("symbol")?.value;
const timeframe = document.getElementById("timeframe")?.value;
const start_date = document.getElementById("start_date")?.value || null;
const end_date = document.getElementById("end_date")?.value || null;
const payload = { symbol, timeframe };
const payload = { symbol, timeframe, mode };
if (start_date) payload.start_date = start_date;
if (end_date) payload.end_date = end_date;
console.log("[calibration_data] download payload:", payload);
// ✅ Persist UI state (para restore tras recargar)
if (mode) localStorage.setItem("calibration.mode", mode);
if (symbol) localStorage.setItem("calibration.symbol", symbol);
if (timeframe) localStorage.setItem("calibration.timeframe", timeframe);
localStorage.setItem("calibration.start_date", start_date || "");
localStorage.setItem("calibration.end_date", end_date || "");
try {
const res = await fetch("/api/v2/calibration/data/download/job", {
method: "POST",
@@ -290,6 +302,29 @@ function renderDataSummary(data) {
document.addEventListener("DOMContentLoaded", () => {
console.log("[calibration_data] DOMContentLoaded ✅");
// --- Restore persisted calibration settings ---
const savedMode = localStorage.getItem("calibration.mode");
const savedSymbol = localStorage.getItem("calibration.symbol");
const savedTimeframe = localStorage.getItem("calibration.timeframe");
const savedStartDate = localStorage.getItem("calibration.start_date");
const savedEndDate = localStorage.getItem("calibration.end_date");
const modeEl = document.getElementById("market_mode");
if (modeEl && savedMode) modeEl.value = savedMode;
const symbolEl = document.getElementById("symbol");
if (symbolEl && savedSymbol) symbolEl.value = savedSymbol;
const tfEl = document.getElementById("timeframe");
if (tfEl && savedTimeframe) tfEl.value = savedTimeframe;
const startEl = document.getElementById("start_date");
if (startEl && savedStartDate) startEl.value = savedStartDate;
const endEl = document.getElementById("end_date");
if (endEl && savedEndDate) endEl.value = savedEndDate;
document
.getElementById("inspect-data-btn")
?.addEventListener("click", inspectCalibrationData);