Refresh fix.
This commit is contained in:
@@ -615,6 +615,14 @@ def refine_bible_route(id):
|
||||
|
||||
return {"status": "queued", "task_id": task.id}
|
||||
|
||||
@app.route('/project/<int:id>/is_refining')
|
||||
@login_required
|
||||
def check_refinement_status(id):
|
||||
proj = db.session.get(Project, id) or Project.query.get_or_404(id)
|
||||
if proj.user_id != current_user.id: return "Unauthorized", 403
|
||||
is_refining = os.path.exists(os.path.join(proj.folder_path, ".refining"))
|
||||
return {"is_refining": is_refining}
|
||||
|
||||
@app.route('/project/<int:id>/refine_bible/confirm', methods=['POST'])
|
||||
@login_required
|
||||
def confirm_bible_refinement(id):
|
||||
|
||||
@@ -605,6 +605,21 @@
|
||||
fetchLog();
|
||||
{% endif %}
|
||||
|
||||
function showRefiningModal() {
|
||||
if (!document.getElementById('refineProgressModal')) {
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="refineProgressModal" tabindex="-1" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered"><div class="modal-content"><div class="modal-body text-center p-4">
|
||||
<div class="spinner-border text-warning mb-3" style="width: 3rem; height: 3rem;"></div>
|
||||
<h4>Refining Bible...</h4><p class="text-muted">The AI is processing your changes.</p>
|
||||
</div></div></div>
|
||||
</div>`;
|
||||
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
||||
}
|
||||
const modal = new bootstrap.Modal(document.getElementById('refineProgressModal'));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function submitRefineModal(event) {
|
||||
event.preventDefault();
|
||||
const form = event.target;
|
||||
@@ -628,23 +643,14 @@
|
||||
const inputModal = bootstrap.Modal.getInstance(inputModalEl);
|
||||
inputModal.hide();
|
||||
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="refineProgressModal" tabindex="-1" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered"><div class="modal-content"><div class="modal-body text-center p-4">
|
||||
<div class="spinner-border text-warning mb-3" style="width: 3rem; height: 3rem;"></div>
|
||||
<h4>Refining Bible...</h4><p class="text-muted">The AI is processing your changes.</p>
|
||||
</div></div></div>
|
||||
</div>`;
|
||||
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
||||
const progressModal = new bootstrap.Modal(document.getElementById('refineProgressModal'));
|
||||
progressModal.show();
|
||||
showRefiningModal();
|
||||
|
||||
const pollInterval = setInterval(() => {
|
||||
fetch(`/task_status/${data.task_id}`).then(r => r.json()).then(status => {
|
||||
if (status.status === 'completed') {
|
||||
clearInterval(pollInterval);
|
||||
if (status.success) {
|
||||
window.location.reload();
|
||||
window.location.href = "/project/{{ project.id }}/bible_comparison";
|
||||
} else {
|
||||
alert("Refinement failed. Please check the logs.");
|
||||
window.location.reload();
|
||||
@@ -660,5 +666,19 @@
|
||||
btn.innerHTML = originalText;
|
||||
});
|
||||
}
|
||||
|
||||
{% if is_refining %}
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
showRefiningModal();
|
||||
const pollInterval = setInterval(() => {
|
||||
fetch("/project/{{ project.id }}/is_refining").then(r => r.json()).then(data => {
|
||||
if (!data.is_refining) {
|
||||
clearInterval(pollInterval);
|
||||
window.location.href = "/project/{{ project.id }}/bible_comparison";
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
});
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user