Fixed callback order for checking if data exists

This commit is contained in:
Joel Collins 2020-04-24 17:29:34 +01:00
parent 9822965335
commit 095e09698d

View file

@ -78,10 +78,6 @@ export default {
.then(response => { .then(response => {
this.settings = this.settings =
response.data.extensions["org.openflexure.camera_stage_mapping"]; 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 => { .catch(error => {
this.modalError(error); // Let mixin handle error this.modalError(error); // Let mixin handle error
@ -89,21 +85,23 @@ export default {
}); });
}, },
checkCalibrationData: function() { updateCalibrationDataAvailability: function() {
axios if ("get_calibration" in this.recalibrationLinks) {
.get(this.recalibrationLinks.get_calibration.href) axios
.then(response => { .get(this.recalibrationLinks.get_calibration.href)
console.log("CSM data:"); .then(response => {
console.log(response.data); console.log("CSM data:");
if (Object.keys(response.data).length === 0) { console.log(response.data);
this.dataAvailable = false; if (Object.keys(response.data).length === 0) {
} else { this.dataAvailable = false;
this.dataAvailable = true; } else {
} this.dataAvailable = true;
}) }
.catch(error => { })
this.modalError(error); // Let mixin handle error .catch(error => {
}); this.modalError(error); // Let mixin handle error
});
}
}, },
getCalibrationData: function() { getCalibrationData: function() {
@ -137,6 +135,8 @@ export default {
if (foundExtension) { if (foundExtension) {
// Get plugin action link // Get plugin action link
this.recalibrationLinks = foundExtension.links; this.recalibrationLinks = foundExtension.links;
// Update whether calibration data is available
this.updateCalibrationDataAvailability();
} else { } else {
this.recalibrationLinks = {}; this.recalibrationLinks = {};
} }