mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 06:08:13 +02:00
now instead of sending status in two places, i'm
just making the client ask for status
This commit is contained in:
@ -100,8 +100,12 @@ document.getElementById("upload-btn").onclick = async () => {
|
||||
commentResultsContainer.classList.add("hidden");
|
||||
refinementResultsContainer.classList.add("hidden");
|
||||
|
||||
uploadStatusEl.classList.remove("hidden");
|
||||
uploadStatusEl.style.color = "green";
|
||||
uploadStatusEl.textContent = json["id"];
|
||||
|
||||
uuid.value = json["id"];
|
||||
document.getElementById("request-status").click();
|
||||
};
|
||||
|
||||
[...document.getElementsByClassName("download-results")].forEach((e) => {
|
||||
@ -178,5 +182,7 @@ document.getElementById("request-status").onclick = async () => {
|
||||
if (json.type == "comment") populateCommentTable(json.results);
|
||||
else if (json.type == "comment") populateRefinementTable(json.results);
|
||||
else console.error(`Unknown type ${data.type}`);
|
||||
} else if (json.status == "waiting") {
|
||||
statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`;
|
||||
}
|
||||
};
|
||||
|
@ -62,20 +62,10 @@ def handler(type_: str, validate_json: Callable, evaluate_submission: Callable):
|
||||
except InvalidJsonFormatError as e:
|
||||
return jsonify({'error': 'Invalid JSON format', 'message': str(e)}), 400
|
||||
|
||||
socketio = current_app.extensions['socketio']
|
||||
sid = request.headers.get('X-Socket-Id')
|
||||
socket_emit = functools.partial(socketio.emit, room=sid)
|
||||
|
||||
process_id = str(uuid.uuid4())
|
||||
subject = Subject(process_id, type_, evaluate_submission)
|
||||
request2status[process_id] = subject
|
||||
|
||||
if sid:
|
||||
socket_emit('successful-upload')
|
||||
socket_emit('started-processing')
|
||||
obs = SocketObserver(sid, socket_emit)
|
||||
subject.registerObserver(obs)
|
||||
|
||||
QUEUE_MANAGER.submit(subject, validated)
|
||||
url = url_for(f".status", id=process_id, _external=True)
|
||||
return jsonify(
|
||||
|
Reference in New Issue
Block a user