diff --git a/openflexure_microscope/api/static/main_v1.js b/openflexure_microscope/api/static/main_v1.js index 760ef1d7..ec62cecd 100644 --- a/openflexure_microscope/api/static/main_v1.js +++ b/openflexure_microscope/api/static/main_v1.js @@ -92,19 +92,19 @@ function updateCaptureList(response) { // For each capture in the response array response.forEach(function(element) { // Store the capture object URI - element_uri = `${baseURI}/camera/capture/${element.id}` + element_uri = `${baseURI}/camera/capture/${element.metadata.id}` // Generate inner HTML from capture object html = `
-
${element.filename}
+
${element.metadata.filename}


- +
` diff --git a/openflexure_microscope/api/v1/blueprints/camera/capture.py b/openflexure_microscope/api/v1/blueprints/camera/capture.py index 0ae6ed23..a033a648 100644 --- a/openflexure_microscope/api/v1/blueprints/camera/capture.py +++ b/openflexure_microscope/api/v1/blueprints/camera/capture.py @@ -25,7 +25,7 @@ class ListAPI(MicroscopeView): :>jsonarr string path: path on pi storage to the capture file, if available :>jsonarr boolean stream: capture stored in-memory as a BytesIO stream :>jsonarr json uri: - **download** *(string)*: api uri to the capture file download - - **metadata** *(string)*: api uri to the capture json representation + - **state** *(string)*: api uri to the capture json representation :>header Content-Type: application/json :status 200: capture found @@ -34,9 +34,9 @@ class ListAPI(MicroscopeView): include_unavailable = get_bool(request.args.get('include_unavailable')) if include_unavailable: - captures = [image.metadata for image in self.microscope.camera.images] + captures = [image.state for image in self.microscope.camera.images] else: - captures = [image.metadata for image in self.microscope.camera.images if image.metadata['available']] + captures = [image.state for image in self.microscope.camera.images if image.state['available']] return jsonify(captures) @@ -49,7 +49,7 @@ class ListAPI(MicroscopeView): for image in self.microscope.camera.images: image.delete() - captures = [image.metadata for image in self.microscope.camera.images] + captures = [image.state for image in self.microscope.camera.images] return jsonify(captures) @@ -94,7 +94,7 @@ class ListAPI(MicroscopeView): :>json string path: path on pi storage to the capture file, if available :>json boolean stream: capture stored in-memory as a BytesIO stream :>json json uri: - **download** *(string)*: api uri to the capture file download - - **metadata** *(string)*: api uri to the capture json representation + - **state** *(string)*: api uri to the capture json representation :
json string path: path on pi storage to the capture file, if available :>json boolean stream: capture stored in-memory as a BytesIO stream :>json json uri: - **download** *(string)*: api uri to the capture file download - - **metadata** *(string)*: api uri to the capture json representation + - **state** *(string)*: api uri to the capture json representation """ capture_obj = self.microscope.camera.image_from_id(capture_id) @@ -180,13 +183,13 @@ class CaptureAPI(MicroscopeView): if not capture_obj: return abort(404) # 404 Not Found - # Get capture metadata - capture_metadata = capture_obj.metadata + # Get capture state + capture_metadata = capture_obj.state - # TODO: Tidy up adding URI to metadata - # Add API routes to returned metadata + # TODO: Tidy up adding URI to state + # Add API routes to returned state uri_dict = { - 'uri': {'metadata': '{}'.format(url_for('.capture', capture_id=capture_obj.id))} + 'uri': {'state': '{}'.format(url_for('.capture', capture_id=capture_obj.id))} } # If available, also add download link @@ -214,11 +217,40 @@ class CaptureAPI(MicroscopeView): def put(self, capture_id): """ - Modify the metadata of a capture (not yet implemented) + Add arbitrary metadata to the capture (stored in an accompanying capture `.yaml` file) .. :quickref: Capture; Update capture metadata + + **Example request**: + + .. sourcecode:: http + + POST /camera/capture HTTP/1.1 + Accept: application/json + + { + "user_id": "ofm_1234", + "patient_number": 1452, + } + + :>header Accept: application/json + + :