From 9822965335e0467adade17e0d3324cdc9ea0ec82 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 24 Apr 2020 16:43:27 +0100 Subject: [PATCH 1/2] Added CSM data download button --- .../cameraStageMappingSettings.vue | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue b/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue index 61995262..eeeb71a1 100644 --- a/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue +++ b/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue @@ -9,6 +9,7 @@
+ Download calibration data +
@@ -41,7 +51,8 @@ export default { return { settings: null, recalibrationLinks: {}, - isCalibrating: false + isCalibrating: false, + dataAvailable: false }; }, @@ -61,11 +72,16 @@ export default { methods: { updateSettings: function() { + // Update links axios .get(this.settingsUri) .then(response => { this.settings = response.data.extensions["org.openflexure.camera_stage_mapping"]; + // Check if existing calibration data is available + if ("get_calibration" in this.recalibrationLinks) { + this.checkCalibrationData(); + } }) .catch(error => { this.modalError(error); // Let mixin handle error @@ -73,6 +89,42 @@ export default { }); }, + checkCalibrationData: function() { + axios + .get(this.recalibrationLinks.get_calibration.href) + .then(response => { + console.log("CSM data:"); + console.log(response.data); + if (Object.keys(response.data).length === 0) { + this.dataAvailable = false; + } else { + this.dataAvailable = true; + } + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); + }, + + getCalibrationData: function() { + axios + .get(this.recalibrationLinks.get_calibration.href) + .then(response => { + if (response.data != {}) { + const data = JSON.stringify(response.data); + const url = window.URL.createObjectURL(new Blob([data])); + const link = document.createElement("a"); + link.href = url; + link.setAttribute("download", "csm_calibration.json"); + document.body.appendChild(link); + link.click(); + } + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); + }, + updateRecalibrationLinks: function() { axios .get(this.pluginsUri) // Get a list of plugins From 095e09698d20ebb8641d7dc192eb92f6696619c5 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 24 Apr 2020 17:29:34 +0100 Subject: [PATCH 2/2] Fixed callback order for checking if data exists --- .../cameraStageMappingSettings.vue | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue b/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue index eeeb71a1..c67b4b89 100644 --- a/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue +++ b/src/components/viewComponents/settingsComponents/cameraStageMappingSettings.vue @@ -78,10 +78,6 @@ export default { .then(response => { this.settings = response.data.extensions["org.openflexure.camera_stage_mapping"]; - // Check if existing calibration data is available - if ("get_calibration" in this.recalibrationLinks) { - this.checkCalibrationData(); - } }) .catch(error => { this.modalError(error); // Let mixin handle error @@ -89,21 +85,23 @@ export default { }); }, - checkCalibrationData: function() { - axios - .get(this.recalibrationLinks.get_calibration.href) - .then(response => { - console.log("CSM data:"); - console.log(response.data); - if (Object.keys(response.data).length === 0) { - this.dataAvailable = false; - } else { - this.dataAvailable = true; - } - }) - .catch(error => { - this.modalError(error); // Let mixin handle error - }); + updateCalibrationDataAvailability: function() { + if ("get_calibration" in this.recalibrationLinks) { + axios + .get(this.recalibrationLinks.get_calibration.href) + .then(response => { + console.log("CSM data:"); + console.log(response.data); + if (Object.keys(response.data).length === 0) { + this.dataAvailable = false; + } else { + this.dataAvailable = true; + } + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); + } }, getCalibrationData: function() { @@ -137,6 +135,8 @@ export default { if (foundExtension) { // Get plugin action link this.recalibrationLinks = foundExtension.links; + // Update whether calibration data is available + this.updateCalibrationDataAvailability(); } else { this.recalibrationLinks = {}; }