From 0c860fec4415583b1a7b7901423f1c594b15fcfa Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 26 Feb 2019 10:49:13 +0000 Subject: [PATCH] Vue autofocus buttons --- src/components/paneNavigate.vue | 49 +++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/components/paneNavigate.vue b/src/components/paneNavigate.vue index f9e94324..e665dc54 100644 --- a/src/components/paneNavigate.vue +++ b/src/components/paneNavigate.vue @@ -62,22 +62,25 @@ -
  • +
  • Autofocus -
    +
    +
    +
    +
    - +
    - +
    - +
    @@ -113,7 +116,8 @@ export default { keysDown: {}, stepXy: 200, stepZz: 50, - setPosition: this.$store.state.apiState.stage.position + setPosition: this.$store.state.apiState.stage.position, + isAutofocusing: false } }, @@ -210,6 +214,36 @@ export default { } }, + runAutofocus: function(dz) { + if (!this.$store.state.moveLock) { + // Lock move requests + this.$store.commit('changeMoveLock', true); + axios.post(this.autofocusApiUri, {dz: dz}) + .then(response => { + console.log("Autofocus Task ID: " + response.data[0].id) + this.isAutofocusing = true + // Start the store polling TaskId for success + self = this; + this.$store.dispatch('pollTask', [response.data[0].id, null, null]) + .then(function() { + UIkit.notification({message: "Finished recalibration.", status: 'success'}) + }) + .catch(error => { + UIkit.notification({message: ` ${error}`, status: 'danger'}) + }) + .finally(() => { + self.isAutofocusing = false + this.$store.commit('changeMoveLock', false) // Release the move lock + }) + }) + .catch(error => { + this.$store.dispatch('handleHTTPError', error); // Let store handle error + self.isAutofocusing = false + this.$store.commit('changeMoveLock', false) // Release the move lock + }) + } + } + }, created: function () { @@ -221,6 +255,9 @@ export default { computed: { positionApiUri: function () { return this.$store.getters.uri + "/stage/position" + }, + autofocusApiUri: function () { + return this.$store.getters.uri + "/plugin/default/autofocus/autofocus" } }