-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: report to user if no markings were detected
Add custom task status with additional metadata/information such as progress of the task or part-failure (e.g. no markings for one of many uploaded files). Add exception for the case that no markings were detected on all uploaded files.
- Loading branch information
1 parent
e55f3e3
commit b635605
Showing
4 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,21 @@ async function poll(url, prefix) { | |
async function onProgress(response) { | ||
// console.log("progress", response); | ||
const result = await response.json(); | ||
setTaskStatus(`${prefix}-status`, `Processing ${result.status}`); | ||
if (result.status === "PROGRESS" && "info" in result) { | ||
const messageProgress = `Processing in ${result.status}: ${result.info.current} of ${result.info.total} uploaded files have been processed.`; | ||
if (result.info.failures && result.info.failures.length) { | ||
const messageFailure = `For following files no markings were detected: ${result.info.failures.join(", ")}.`; | ||
const messageContact = "Please feel free to report this failure ([email protected])"; | ||
setTaskStatus( | ||
`${prefix}-status`, | ||
[messageProgress, messageFailure, messageContact].join(" "), | ||
); | ||
} else { | ||
setTaskStatus(`${prefix}-status`, messageProgress); | ||
} | ||
} else { | ||
setTaskStatus(`${prefix}-status`, `Processing ${result.status}`); | ||
} | ||
} | ||
|
||
async function onValid(response) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters