diff --git a/src/aind_qc_portal/docdb/database.py b/src/aind_qc_portal/docdb/database.py
index c1fd43f..4de5dfd 100644
--- a/src/aind_qc_portal/docdb/database.py
+++ b/src/aind_qc_portal/docdb/database.py
@@ -20,7 +20,17 @@
)
-def qc_from_id(id: str):
+def qc_from_id(id: str) -> QualityControl | None:
+ """Get the QC object from the database for a given ID
+
+ Parameters
+ ----------
+ id : str
+
+ Returns
+ -------
+ QualityControl
+ """
response = client.retrieve_docdb_records(filter_query={"_id": id}, limit=1)
if len(response) == 0:
return None
@@ -33,9 +43,7 @@ def qc_update_to_id(id: str, qc: QualityControl):
response = client.upsert_one_docdb_record(
record={"_id": id, "quality_control": qc.model_dump()}
)
- print(response)
- if response.status_code != 200:
- print(response.json())
+ return response
@pn.cache()
diff --git a/src/aind_qc_portal/panel/quality_control.py b/src/aind_qc_portal/panel/quality_control.py
index da96295..b88cce1 100644
--- a/src/aind_qc_portal/panel/quality_control.py
+++ b/src/aind_qc_portal/panel/quality_control.py
@@ -21,9 +21,12 @@ def __init__(self, id, **params):
self.id = id
+ # Set up the submission area
self.submit_button = pn.widgets.Button(
name="Submit changes", button_type="success",
)
+ self.submit_error = pn.widgets.StaticText("")
+ self.submit_col = pn.Column(self.submit_button, self.submit_error)
pn.bind(self.submit_changes, self.submit_button, watch=True)
self.hidden_html = pn.pane.HTML("")
@@ -96,9 +99,14 @@ def submit_changes(self, *event):
self.hidden_html.object = f""
return
- qc_update_to_id(self.id, self.data)
- self.submit_button.disabled = True
- self.hidden_html.object = ""
+ response = qc_update_to_id(self.id, self.data)
+
+ if response.status_code != 200:
+ self.submit_error.value = f"Error ({response.status_code}) submitting changes: {response.text}"
+ return
+ else:
+ self.submit_button.disabled = True
+ self.hidden_html.object = ""
def _update_modality_filter(self, event):
self.modality_filter = event.new
@@ -149,10 +157,11 @@ def panel(self):
# state row
state_row = pn.Row(state_pane, notes_box)
quality_control_pane = pn.Column(header, state_row)
+
# button
header_row = pn.Row(
- quality_control_pane, pn.HSpacer(), self.submit_button
+ quality_control_pane, pn.HSpacer(), self.submit_col
)
# filters for modality and stage