Skip to content

Commit

Permalink
enable scan page auto reload
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellm committed Jan 17, 2025
1 parent 799614c commit ce49616
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/tasso/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Annotated

from fastapi import APIRouter, Depends
from fastapi.responses import JSONResponse
from safir.dependencies.db_session import db_session_dependency
from safir.dependencies.logger import logger_dependency
from safir.metadata import get_metadata
Expand Down Expand Up @@ -147,14 +148,13 @@ async def get_unclassified_subject(


@external_router.put(
"/classify_and_get_next",
summary="Store classification for a given subject and return "
"an unclassified one.",
"/classify_and_reload",
summary="Store classification for a given subject and reload",
)
async def put_classification_and_return_new(
async def put_classification_and_reload(
classification: Classification,
logger: Annotated[BoundLogger, Depends(logger_dependency)],
) -> Subject | None:
) -> JSONResponse:
await put_classification(classification, logger)

return await get_unclassified_subject(classification.user, logger)
return JSONResponse(content={}, headers={"HX-Refresh": "true"})
8 changes: 4 additions & 4 deletions src/tasso/webapp/templates/pages/scan.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "pages/base.html" %}
{% block title %} subject {% endblock %}
{% block content %}
<div id="scan_content" hx-get="/scan" hx-swap="innerHTML">
<div id="scan_content">
<div class="flex pl-3 items-center">
<span class="text-large" name="subject_id">{{subject.subject_id}}</span>
&nbsp;
Expand All @@ -17,7 +17,7 @@

<div class="flex pl-3 items-center">
<button class="flex items-center px-4 py-3 border"
hx-put="/tasso/classify_and_get_next"
hx-put="/tasso/classify_and_reload"
hx-vals='js:{"user":"{{user}}",
"subject_id":"{{subject.subject_id}}",
"run_id":"{{subject.run_id}}",
Expand All @@ -26,14 +26,14 @@
"flags":0,
"time_labeled":Date.now()}'
hx-ext="json-enc"
hx-target="#scan_content">
hx-refresh="True">
Real
</button>
</div>

<div class="flex pl-3 items-center">
<button class="flex items-center px-4 py-3 border"
hx-put="/tasso/classify_and_get_next"
hx-put="/tasso/classify_and_reload"
hx-vals='js:{"user":"{{user}}",
"subject_id":"{{subject.subject_id}}",
"run_id":"{{subject.run_id}}",
Expand Down

0 comments on commit ce49616

Please sign in to comment.