From c0fcd22cc3095523f2bbe0d183e61d4aa55bf527 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 24 Nov 2020 12:26:14 +0000 Subject: [PATCH] feat: Added backlash and settle time settings --- .../settingsComponents/stageSettings.vue | 153 +++++++++++++++--- 1 file changed, 130 insertions(+), 23 deletions(-) diff --git a/openflexure_microscope/api/static/src/components/tabContentComponents/settingsComponents/stageSettings.vue b/openflexure_microscope/api/static/src/components/tabContentComponents/settingsComponents/stageSettings.vue index fae3462b..16cd8fda 100644 --- a/openflexure_microscope/api/static/src/components/tabContentComponents/settingsComponents/stageSettings.vue +++ b/openflexure_microscope/api/static/src/components/tabContentComponents/settingsComponents/stageSettings.vue @@ -1,31 +1,96 @@ @@ -40,11 +105,20 @@ export default { data: function() { return { - stageType: "MissingStage" + stageType: "MissingStage", + backlash: { + x: undefined, + y: undefined, + z: undefined + }, + settle_time: undefined }; }, computed: { + settingsUri: function() { + return `${this.$store.getters.baseUri}/api/v2/instrument/settings`; + }, stageTypeUri: function() { return `${this.$store.getters.baseUri}/api/v2/instrument/stage/type`; } @@ -52,9 +126,42 @@ export default { mounted() { this.getStageType(); + this.updateSettings(); }, methods: { + updateSettings: function() { + axios + .get(this.settingsUri) + .then(response => { + const stageSettings = response.data.stage; + this.backlash.x = stageSettings.backlash.x; + this.backlash.y = stageSettings.backlash.y; + this.backlash.z = stageSettings.backlash.z; + this.settle_time = stageSettings.settle_time; + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); + }, + applySettingsRequest: function() { + var payload = { + stage: { + backlash: this.backlash + } + }; + // Send request to update settings + axios + .put(this.settingsUri, payload) + .then(() => { + // Update local settings + this.updateSettings(); + this.modalNotify("Stage settings applied."); + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); + }, getStageType: function() { axios .get(this.stageTypeUri)