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