Spaces:
Running
Running
Commit ·
ad5ab1d
1
Parent(s): 45049a5
Fixed error happening during parallel sessions
Browse filesmodified: ui/static/app.js
modified: ui_app.py
- ui/static/app.js +11 -3
- ui_app.py +13 -8
ui/static/app.js
CHANGED
|
@@ -155,6 +155,14 @@
|
|
| 155 |
}[char]));
|
| 156 |
}
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
function renderCleanProgressRows() {
|
| 159 |
cleanProgressPanel.classList.add("active");
|
| 160 |
cleanProgressSummary.textContent = `${cleanProgressOrder.length} column${cleanProgressOrder.length === 1 ? "" : "s"}`;
|
|
@@ -220,7 +228,7 @@
|
|
| 220 |
<strong>Blueprint applied</strong>
|
| 221 |
<div class="status">${changed ? changed[1] : "0"} workbook row value${changed && changed[1] === "1" ? "" : "s"} updated from human overrides.</div>
|
| 222 |
<div class="status">${added ? added[1] : "0"} new unique reference value${added && added[1] === "1" ? "" : "s"} added to manual references.</div>
|
| 223 |
-
<a class="download-link" href="/download-applied-workbook">Download Cleaned Workbook</a>
|
| 224 |
`;
|
| 225 |
}
|
| 226 |
|
|
@@ -412,8 +420,8 @@
|
|
| 412 |
cleanResult.innerHTML = `
|
| 413 |
<strong>Blueprint generated</strong>
|
| 414 |
<div class="status">Blueprint saved for this session.</div>
|
| 415 |
-
<a class="download-link" href="/download-blueprint">Download Blueprint</a>
|
| 416 |
-
<a class="download-link" href="/download-cleaned-workbook">Download Cleaned Workbook</a>
|
| 417 |
`;
|
| 418 |
runStatus.textContent = "Finished.";
|
| 419 |
} else {
|
|
|
|
| 155 |
}[char]));
|
| 156 |
}
|
| 157 |
|
| 158 |
+
function downloadUrl(path, filename, endpoint) {
|
| 159 |
+
const params = new URLSearchParams({ path });
|
| 160 |
+
if (filename) {
|
| 161 |
+
params.set("filename", filename);
|
| 162 |
+
}
|
| 163 |
+
return `${endpoint}?${params.toString()}`;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
function renderCleanProgressRows() {
|
| 167 |
cleanProgressPanel.classList.add("active");
|
| 168 |
cleanProgressSummary.textContent = `${cleanProgressOrder.length} column${cleanProgressOrder.length === 1 ? "" : "s"}`;
|
|
|
|
| 228 |
<strong>Blueprint applied</strong>
|
| 229 |
<div class="status">${changed ? changed[1] : "0"} workbook row value${changed && changed[1] === "1" ? "" : "s"} updated from human overrides.</div>
|
| 230 |
<div class="status">${added ? added[1] : "0"} new unique reference value${added && added[1] === "1" ? "" : "s"} added to manual references.</div>
|
| 231 |
+
<a class="download-link" href="${downloadUrl(applyWorkbookPath, "", "/download-applied-workbook")}">Download Cleaned Workbook</a>
|
| 232 |
`;
|
| 233 |
}
|
| 234 |
|
|
|
|
| 420 |
cleanResult.innerHTML = `
|
| 421 |
<strong>Blueprint generated</strong>
|
| 422 |
<div class="status">Blueprint saved for this session.</div>
|
| 423 |
+
<a class="download-link" href="${downloadUrl(generatedBlueprintPath, "Blueprint.xlsx", "/download-blueprint")}">Download Blueprint</a>
|
| 424 |
+
<a class="download-link" href="${downloadUrl(cleanPath, "", "/download-cleaned-workbook")}">Download Cleaned Workbook</a>
|
| 425 |
`;
|
| 426 |
runStatus.textContent = "Finished.";
|
| 427 |
} else {
|
ui_app.py
CHANGED
|
@@ -311,9 +311,10 @@ def sheets_endpoint():
|
|
| 311 |
@app.route("/download-blueprint")
|
| 312 |
def download_blueprint():
|
| 313 |
state = get_state()
|
| 314 |
-
|
|
|
|
| 315 |
return jsonify({"error": "Blueprint has not been generated yet."}), 404
|
| 316 |
-
blueprint_path = resolve_allowed_path(
|
| 317 |
if not blueprint_path.exists():
|
| 318 |
return jsonify({"error": "Blueprint has not been generated yet."}), 404
|
| 319 |
return send_file(blueprint_path, as_attachment=True, download_name="Blueprint.xlsx")
|
|
@@ -322,30 +323,34 @@ def download_blueprint():
|
|
| 322 |
@app.route("/download-cleaned-workbook")
|
| 323 |
def download_cleaned_workbook():
|
| 324 |
state = get_state()
|
| 325 |
-
|
|
|
|
| 326 |
return jsonify({"error": "Cleaned workbook is not available."}), 404
|
| 327 |
-
workbook_path = resolve_allowed_path(
|
| 328 |
if not workbook_path.is_file():
|
| 329 |
return jsonify({"error": "Cleaned workbook is not available."}), 404
|
|
|
|
| 330 |
return send_file(
|
| 331 |
workbook_path,
|
| 332 |
as_attachment=True,
|
| 333 |
-
download_name=f"cleaned_{
|
| 334 |
)
|
| 335 |
|
| 336 |
|
| 337 |
@app.route("/download-applied-workbook")
|
| 338 |
def download_applied_workbook():
|
| 339 |
state = get_state()
|
| 340 |
-
|
|
|
|
| 341 |
return jsonify({"error": "Applied workbook is not available."}), 404
|
| 342 |
-
workbook_path = resolve_allowed_path(
|
| 343 |
if not workbook_path.is_file():
|
| 344 |
return jsonify({"error": "Applied workbook is not available."}), 404
|
|
|
|
| 345 |
return send_file(
|
| 346 |
workbook_path,
|
| 347 |
as_attachment=True,
|
| 348 |
-
download_name=f"cleaned_{
|
| 349 |
)
|
| 350 |
|
| 351 |
|
|
|
|
| 311 |
@app.route("/download-blueprint")
|
| 312 |
def download_blueprint():
|
| 313 |
state = get_state()
|
| 314 |
+
requested_path = request.args.get("path") or state["apply_blueprint_path"]
|
| 315 |
+
if not requested_path:
|
| 316 |
return jsonify({"error": "Blueprint has not been generated yet."}), 404
|
| 317 |
+
blueprint_path = resolve_allowed_path(requested_path, APP_ROOT, ALLOWED_FILE_ROOTS)
|
| 318 |
if not blueprint_path.exists():
|
| 319 |
return jsonify({"error": "Blueprint has not been generated yet."}), 404
|
| 320 |
return send_file(blueprint_path, as_attachment=True, download_name="Blueprint.xlsx")
|
|
|
|
| 323 |
@app.route("/download-cleaned-workbook")
|
| 324 |
def download_cleaned_workbook():
|
| 325 |
state = get_state()
|
| 326 |
+
requested_path = request.args.get("path") or state["clean_path"]
|
| 327 |
+
if not requested_path:
|
| 328 |
return jsonify({"error": "Cleaned workbook is not available."}), 404
|
| 329 |
+
workbook_path = resolve_allowed_path(requested_path, APP_ROOT, ALLOWED_FILE_ROOTS)
|
| 330 |
if not workbook_path.is_file():
|
| 331 |
return jsonify({"error": "Cleaned workbook is not available."}), 404
|
| 332 |
+
download_name = request.args.get("filename") or state["clean_filename"] or workbook_path.name
|
| 333 |
return send_file(
|
| 334 |
workbook_path,
|
| 335 |
as_attachment=True,
|
| 336 |
+
download_name=f"cleaned_{download_name}",
|
| 337 |
)
|
| 338 |
|
| 339 |
|
| 340 |
@app.route("/download-applied-workbook")
|
| 341 |
def download_applied_workbook():
|
| 342 |
state = get_state()
|
| 343 |
+
requested_path = request.args.get("path") or state["apply_workbook_path"]
|
| 344 |
+
if not requested_path:
|
| 345 |
return jsonify({"error": "Applied workbook is not available."}), 404
|
| 346 |
+
workbook_path = resolve_allowed_path(requested_path, APP_ROOT, ALLOWED_FILE_ROOTS)
|
| 347 |
if not workbook_path.is_file():
|
| 348 |
return jsonify({"error": "Applied workbook is not available."}), 404
|
| 349 |
+
download_name = request.args.get("filename") or state["apply_workbook_filename"] or workbook_path.name
|
| 350 |
return send_file(
|
| 351 |
workbook_path,
|
| 352 |
as_attachment=True,
|
| 353 |
+
download_name=f"cleaned_{download_name}",
|
| 354 |
)
|
| 355 |
|
| 356 |
|