Fixes
This commit is contained in:
@@ -310,10 +310,17 @@ def api_submit_review(task_id):
|
||||
return jsonify({"error": "verdict is required"}), 400
|
||||
|
||||
try:
|
||||
result = api_post(f"task/{task_id}/complete", {
|
||||
"results": {"reviewer_verdict": verdict},
|
||||
api_response = api_post(f"task/{task_id}/complete", {
|
||||
"results": {
|
||||
"review_verdict": verdict,
|
||||
},
|
||||
})
|
||||
return jsonify({
|
||||
"status": "completed",
|
||||
"task_id": task_id,
|
||||
"verdict": verdict,
|
||||
"api_response": api_response,
|
||||
})
|
||||
return jsonify({"status": "completed", "task_id": task_id, "verdict": verdict})
|
||||
except requests.RequestException as exc:
|
||||
return jsonify({"error": f"API error: {exc}"}), 503
|
||||
|
||||
@@ -445,6 +452,7 @@ _REVIEW_TEMPLATE = """
|
||||
.actions{display:flex;gap:12px;margin-top:14px}
|
||||
.action-btn{flex:1;padding:14px;border:2px solid #dee2e6;border-radius:8px;background:#fff;cursor:pointer;font-size:15px;font-weight:600;transition:all .15s;text-align:center}
|
||||
.action-btn:hover{border-color:#007bff;transform:translateY(-1px);box-shadow:0 2px 8px rgba(0,0,0,.1)}
|
||||
.action-btn:disabled{opacity:.6;cursor:not-allowed;transform:none}
|
||||
.action-btn.false-positive:hover{border-color:#dc3545;color:#dc3545;background:#fff5f5}
|
||||
.action-btn.correct:hover{border-color:#28a745;color:#28a745;background:#f0fff4}
|
||||
.skip-btn:hover{border-color:#6c757d;color:#6c757d;background:#f8f9fa}
|
||||
@@ -453,6 +461,7 @@ _REVIEW_TEMPLATE = """
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="flash"></div>
|
||||
<div class="header">
|
||||
<h1>VideoDetect</h1>
|
||||
<a href="/">« Back to queue</a>
|
||||
@@ -497,33 +506,58 @@ _REVIEW_TEMPLATE = """
|
||||
|
||||
<script>
|
||||
async function submitVerdict(verdict) {
|
||||
const resp = await fetch(`/api/review/submit/{{ video.id }}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({verdict})
|
||||
});
|
||||
if (resp.ok) {
|
||||
showFlash('Verdict submitted ✓', '#28a745');
|
||||
setTimeout(() => location.href = '/', 1000);
|
||||
} else {
|
||||
const err = await resp.json();
|
||||
alert(err.error || 'Submission failed');
|
||||
setActionButtonsDisabled(true);
|
||||
showFlash('Submitting verdict...', '#007bff');
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/review/submit/{{ video.id }}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({verdict})
|
||||
});
|
||||
const body = await resp.json().catch(() => ({}));
|
||||
if (resp.ok) {
|
||||
showFlash('Verdict submitted', '#28a745');
|
||||
setTimeout(() => location.href = '/', 1000);
|
||||
} else {
|
||||
alert(body.error || 'Submission failed');
|
||||
setActionButtonsDisabled(false);
|
||||
}
|
||||
} catch (err) {
|
||||
alert(`Submission failed: ${err.message}`);
|
||||
setActionButtonsDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function skipTask() {
|
||||
if (!confirm('Skip this task? It will be returned to the PENDING queue.')) return;
|
||||
const resp = await fetch(`/api/review/skip/{{ video.id }}`, {method: 'POST'});
|
||||
if (resp.ok) {
|
||||
showFlash('Task skipped, returned to queue', '#6c757d');
|
||||
setTimeout(() => location.href = '/', 1000);
|
||||
} else {
|
||||
alert('Skip failed');
|
||||
setActionButtonsDisabled(true);
|
||||
showFlash('Skipping task...', '#6c757d');
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/review/skip/{{ video.id }}`, {method: 'POST'});
|
||||
if (resp.ok) {
|
||||
showFlash('Task skipped, returned to queue', '#6c757d');
|
||||
setTimeout(() => location.href = '/', 1000);
|
||||
} else {
|
||||
alert('Skip failed');
|
||||
setActionButtonsDisabled(false);
|
||||
}
|
||||
} catch (err) {
|
||||
alert(`Skip failed: ${err.message}`);
|
||||
setActionButtonsDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
function setActionButtonsDisabled(disabled) {
|
||||
document.querySelectorAll('.action-btn').forEach((button) => {
|
||||
button.disabled = disabled;
|
||||
});
|
||||
}
|
||||
|
||||
function showFlash(msg, color) {
|
||||
const el = document.getElementById('flash');
|
||||
if (!el) return;
|
||||
el.textContent = msg; el.style.background = color; el.style.display = 'block';
|
||||
setTimeout(() => el.style.display = 'none', 2500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user