From 7c662b2787078af908c307a5b3ec4986e4282b6f Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Mon, 11 Dec 2023 22:23:32 +0000 Subject: [PATCH] Added capture buttons to navigate pane --- .../navigateComponents/paneNavigate.vue | 95 +++++++++++-------- 1 file changed, 57 insertions(+), 38 deletions(-) diff --git a/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue b/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue index e6021f41..d2d8b403 100644 --- a/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue +++ b/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue @@ -143,7 +143,7 @@ v-if="fastAutofocusUri" :submit-url="fastAutofocusUri" :submit-data="{ dz: 2000 }" - :submit-label="'Fast'" + :submit-label="'Autofocus'" :button-primary="false" :submit-on-event="'globalFastAutofocusEvent'" @taskStarted="isAutofocusing = 1" @@ -151,32 +151,34 @@ @error="modalError" > + + + +
  • + Image Capture +
    +
    + +
    -
    - -
    - -
    - -
    +
    +
  • @@ -220,10 +222,7 @@ export default { }, setPosition: null, isAutofocusing: 0, - moveLock: false, - fastAutofocusUri: null, - normalAutofocusUri: null, - moveInImageCoordinatesUri: null + moveLock: false }; }, @@ -239,6 +238,18 @@ export default { }, positionStatusUri: function() { return `${this.baseUri}/stage/position`; + }, + fastAutofocusUri: function() { + return this.thingActionUrl("autofocus", "fast_autofocus"); + }, + captureUri: function() { + return this.thingActionUrl("camera", "capture_jpeg"); + }, + moveInImageCoordinatesUri: function() { + return this.thingActionUrl( + "camera_stage_mapping", + "move_in_image_coordinates" + ); } }, @@ -282,8 +293,6 @@ export default { // Update the current position in text boxes this.updatePosition(); // Look for autofocus plugin - this.updateAutofocusUri(); - this.updateMoveInImageCoordinatesUri(); }, beforeDestroy() { @@ -381,12 +390,22 @@ export default { }); }, - updateAutofocusUri: function() { - this.fastAutofocusUri = `${this.baseUri}/autofocus/fast_autofocus`; - }, - - updateMoveInImageCoordinatesUri: function() { - this.moveInImageCoordinatesUri = `${this.baseUri}/camera_stage_mapping/move_in_image_coordinates`; + handleCaptureResponse: async function(response) { + // Retrieve the captured image and save it + let imageUri = response.output.href; + if (!imageUri) { + this.modalError("No image URI returned from capture task."); + console.log(`Capture resulted in response ${response}`); + return; + } + // To save the returned data, we make a virtual link and click it + let imageResponse = await axios.get(imageUri, { responseType: "blob" }); + const url = window.URL.createObjectURL(new Blob([imageResponse.data])); + const link = document.createElement("a"); + link.href = url; + link.setAttribute("download", `OFM_${new Date().toISOString()}.jpeg`); + document.body.appendChild(link); + link.click(); } } };