fix
This commit is contained in:
parent
8f84774880
commit
793f6f9a7e
@ -8,7 +8,6 @@ class PaperProcessor {
|
|||||||
this.searchForm = document.getElementById("searchPaperForm");
|
this.searchForm = document.getElementById("searchPaperForm");
|
||||||
this.searchInput = document.getElementById("paperSearchInput");
|
this.searchInput = document.getElementById("paperSearchInput");
|
||||||
this.searchResults = document.getElementById("searchResults");
|
this.searchResults = document.getElementById("searchResults");
|
||||||
this.processingStatus = document.getElementById("processingStatus");
|
|
||||||
this.paperSearchResults = document.getElementById("paperSearchResults");
|
this.paperSearchResults = document.getElementById("paperSearchResults");
|
||||||
this.scraperSelect = document.getElementById("scraperSelect");
|
this.scraperSelect = document.getElementById("scraperSelect");
|
||||||
|
|
||||||
@ -153,16 +152,15 @@ class PaperProcessor {
|
|||||||
* @param {string} paperId - The ID of the paper to process
|
* @param {string} paperId - The ID of the paper to process
|
||||||
*/
|
*/
|
||||||
async processSinglePaper(paperId) {
|
async processSinglePaper(paperId) {
|
||||||
if (!this.processingStatus || !this.scraperSelect) return;
|
if (!this.scraperSelect) return;
|
||||||
|
|
||||||
// Disable all process buttons to prevent multiple clicks
|
// Disable all process buttons to prevent multiple clicks
|
||||||
document.querySelectorAll(".process-paper-btn").forEach((btn) => {
|
document.querySelectorAll(".process-paper-btn").forEach((btn) => {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show processing status
|
// Show processing status via flash message
|
||||||
this.processingStatus.textContent = "Processing paper...";
|
showFlashMessage("Processing paper...", "info");
|
||||||
this.processingStatus.classList.remove("d-none");
|
|
||||||
|
|
||||||
// Get selected scraper
|
// Get selected scraper
|
||||||
const selectedScraper = this.scraperSelect.value;
|
const selectedScraper = this.scraperSelect.value;
|
||||||
@ -176,9 +174,6 @@ class PaperProcessor {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.processingStatus.textContent = data.message;
|
|
||||||
this.processingStatus.className = "alert alert-success mt-3";
|
|
||||||
|
|
||||||
// Update status in the search results
|
// Update status in the search results
|
||||||
const row = document
|
const row = document
|
||||||
.querySelector(`.process-paper-btn[data-paper-id="${paperId}"]`)
|
.querySelector(`.process-paper-btn[data-paper-id="${paperId}"]`)
|
||||||
@ -190,20 +185,16 @@ class PaperProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show notification
|
// Show success notification
|
||||||
showFlashMessage(data.message, "success");
|
showFlashMessage(data.message, "success");
|
||||||
|
|
||||||
// Set up polling to check paper status and refresh activity
|
// Set up polling to check paper status and refresh activity
|
||||||
this.pollPaperStatus(paperId, 3000, 20);
|
this.pollPaperStatus(paperId, 3000, 20);
|
||||||
} else {
|
} else {
|
||||||
this.processingStatus.textContent = data.message;
|
|
||||||
this.processingStatus.className = "alert alert-danger mt-3";
|
|
||||||
showFlashMessage(data.message, "error");
|
showFlashMessage(data.message, "error");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error processing paper:", error);
|
console.error("Error processing paper:", error);
|
||||||
this.processingStatus.textContent = "Error: Could not process paper";
|
|
||||||
this.processingStatus.className = "alert alert-danger mt-3";
|
|
||||||
showFlashMessage("Error processing paper", "error");
|
showFlashMessage("Error processing paper", "error");
|
||||||
} finally {
|
} finally {
|
||||||
// Re-enable the process buttons after a short delay
|
// Re-enable the process buttons after a short delay
|
||||||
@ -257,13 +248,11 @@ class PaperProcessor {
|
|||||||
// Update processing status message if status changed
|
// Update processing status message if status changed
|
||||||
if (paper.status !== "Pending") {
|
if (paper.status !== "Pending") {
|
||||||
if (paper.status === "Done") {
|
if (paper.status === "Done") {
|
||||||
this.processingStatus.textContent = `Paper processed successfully: ${paper.title}`;
|
showFlashMessage(`Paper processed successfully: ${paper.title}`, "success");
|
||||||
this.processingStatus.className = "alert alert-success mt-3";
|
|
||||||
} else if (paper.status === "Failed") {
|
} else if (paper.status === "Failed") {
|
||||||
this.processingStatus.textContent = `Paper processing failed: ${
|
showFlashMessage(`Paper processing failed: ${
|
||||||
paper.error_msg || "Unknown error"
|
paper.error_msg || "Unknown error"
|
||||||
}`;
|
}`, "error");
|
||||||
this.processingStatus.className = "alert alert-danger mt-3";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,23 +271,12 @@ class PaperProcessor {
|
|||||||
this.onChartRefresh();
|
this.onChartRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show notification if status changed
|
|
||||||
if (paper.status !== "Pending") {
|
|
||||||
const status = paper.status === "Done" ? "success" : "error";
|
|
||||||
const message =
|
|
||||||
paper.status === "Done"
|
|
||||||
? `Paper processed successfully: ${paper.title}`
|
|
||||||
: `Paper processing failed: ${
|
|
||||||
paper.error_msg || "Unknown error"
|
|
||||||
}`;
|
|
||||||
showFlashMessage(message, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we hit max attempts but status is still pending, show a message
|
// If we hit max attempts but status is still pending, show a message
|
||||||
if (paper.status === "Pending" && attempts >= maxAttempts) {
|
if (paper.status === "Pending" && attempts >= maxAttempts) {
|
||||||
this.processingStatus.textContent =
|
showFlashMessage(
|
||||||
"Paper is still being processed. Check the activity log for updates.";
|
"Paper is still being processed. Check the activity log for updates.",
|
||||||
this.processingStatus.className = "alert alert-info mt-3";
|
"info"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user