Commit 55ac3379 authored by Joel Collins's avatar Joel Collins
Browse files

Handle missing stage in calibration modal

parent 2616019a
Loading
Loading
Loading
Loading
+51 −14
Original line number Diff line number Diff line
@@ -62,6 +62,14 @@
            >
          </p>
        </div>
        <div v-else-if="!canCSMCalibrated">
          <p>
            <b
              >No stage connected. Please skip this step, or connect a valid
              stage, then reboot your microscope.</b
            >
          </p>
        </div>
        <div v-else>
          <p>
            <b
@@ -164,7 +172,8 @@ export default {
    return {
      ready: false,
      stepValue: 0,
      settings: {}
      settings: {},
      config: {}
    };
  },

@@ -172,6 +181,9 @@ export default {
    settingsUri: function() {
      return `${this.$store.getters.baseUri}/api/v2/instrument/settings`;
    },
    configUri: function() {
      return `${this.$store.getters.baseUri}/api/v2/instrument/configuration`;
    },
    availablePluginTitles: function() {
      return this.availablePlugins.map(a => a.title);
    },
@@ -193,14 +205,24 @@ export default {
      }
    },
    canCSMCalibrated: function() {
      return this.availablePluginTitles.includes(
      // Assert CSM extension is enabled
      var extensionEnabled = this.availablePluginTitles.includes(
        "org.openflexure.camera_stage_mapping"
      );
      // Assert real stage is connected
      var stageConnected = this.config.stage.type !== "MissingStage";
      // Combine
      return stageConnected && extensionEnabled;
    },
    canLSTCalibrated: function() {
      return this.availablePluginTitles.includes(
      // Assert LST extension is enabled
      var extensionEnabled = this.availablePluginTitles.includes(
        "org.openflexure.calibration.picamera"
      );
      // Assert real camera is connected
      var cameraConnected = this.config.camera.type !== "MissingCamera";
      // Combine
      return cameraConnected && extensionEnabled;
    },
    isUseful: function() {
      var CSMUseful = this.canCSMCalibrated && !this.isCSMCalibrated;
@@ -212,7 +234,11 @@ export default {
  methods: {
    show: function() {
      // Get current settings
      this.getSettings().then(() => {
      this.getSettings()
        .then(() => {
          return this.getConfig();
        })
        .then(() => {
          // Check if this calibration wizard can actually do anything useful
          console.log(this.isUseful);
          if (this.isUseful) {
@@ -243,6 +269,17 @@ export default {
        });
    },

    getConfig: function() {
      return axios
        .get(this.configUri)
        .then(response => {
          this.config = response.data;
        })
        .catch(error => {
          this.modalError(error); // Let mixin handle error
        });
    },

    decrement: function() {
      if (this.stepValue > 0) {
        this.stepValue = this.stepValue - 1;