Loading src/components/controlComponents/settingsComponents/cameraSettings.vue +18 −39 Original line number Diff line number Diff line Loading @@ -26,13 +26,15 @@ <!--Show auto calibrate if default plugin is enabled--> <div v-if="this.$store.state.apiState.plugin.includes('default_camera_calibration')"> <div v-if="isCalibrating"> <progressBar/> </div> <div v-bind:hidden="isCalibrating"> <button type="button" v-on:click="recalibrateConfirm()" class="uk-button uk-button-default uk-form-small uk-float-right uk-margin-small uk-width-1-1">Auto-Calibrate</button> </div> <taskSubmitter v-bind:canTerminate="false" v-bind:requiresConfirmation="true" v-bind:confirmationMessage="'Start recalibration? This may take a while, and the microscope will be locked during this time.'" v-bind:submitURL="recalibrateApiUri" v-bind:submitLabel="'Auto-Calibrate (Task)'" v-on:response="onRecalibrateResponse" v-on:error="onRecalibrateError"> </taskSubmitter> </div> </form> Loading @@ -43,14 +45,14 @@ <script> import axios from 'axios' import progressBar from "../../genericComponents/progressBar" import taskSubmitter from "../../genericComponents/taskSubmitter" // Export main app export default { name: 'microscopeSettings', components: { progressBar taskSubmitter }, data: function () { Loading Loading @@ -95,37 +97,14 @@ export default { this.modalError(error) // Let mixin handle error }) }, recalibrateConfirm: function() { var context = this this.modalConfirm('Start recalibration? This may take a while, and the microscope will be locked during this time.') .then(function() { context.recalibrateRequest() }, function () { console.log('Rejected recalibration.') }) }, recalibrateRequest: function() { // Send move request axios.post(this.recalibrateApiUri) .then(response => { console.log("Task ID: " + response.data.id) this.isCalibrating = true return this.$store.dispatch('pollTask', [response.data.id, null, null]) }) .then(() => { onRecalibrateResponse: function() { this.modalNotify("Finished recalibration.") return new Promise(r => setTimeout(r, 500)) // wait 500ms before updating config, so it's fresh }) .then(() => { return this.$store.dispatch('updateConfig'); }) .then(this.updateInputValues) .catch(error => { }, onRecalibrateError: function(error) { this.modalError(error) // Let mixin handle error }) .finally(() => { this.isCalibrating = false }) } }, Loading src/components/genericComponents/taskSubmitter.vue +31 −4 Original line number Diff line number Diff line Loading @@ -7,10 +7,10 @@ <div v-else class="indeterminate"></div> </div> <button type="button" v-on:click="terminateTask()" class="uk-button uk-button-danger uk-form-small uk-margin uk-float-right uk-width-1-1">Terminate</button> <button v-if="canTerminate" type="button" v-on:click="terminateTask()" class="uk-button uk-button-danger uk-form-small uk-margin uk-float-right uk-width-1-1">Terminate</button> </div> <button type="button" v-on:click="startTask()" v-bind:hidden="taskRunning" class="uk-button uk-button-primary uk-form-small uk-margin uk-float-right uk-width-1-1">{{ submitLabel }}</button> <button type="button" v-on:click="bootstrapTask()" v-bind:hidden="taskRunning" class="uk-button uk-button-primary uk-form-small uk-margin uk-float-right uk-width-1-1">{{ submitLabel }}</button> </div> </template> Loading @@ -29,7 +29,7 @@ export default { submitData: { type: Object, required: false, default: {} default: () => ({}) }, pollInterval: { type: Number, Loading @@ -46,6 +46,21 @@ export default { required: false, default: "Submit" }, canTerminate: { type: Boolean, required: false, default: true }, requiresConfirmation: { type: Boolean, required: false, default: false }, confirmationMessage: { type: String, required: false, default: "Start task?" } }, data: function () { Loading @@ -64,6 +79,18 @@ export default { }, methods: { bootstrapTask: function() { if (this.requiresConfirmation) { this.modalConfirm(this.confirmationMessage) .then(() => { this.startTask() }, () => {}) } else { this.startTask() } }, startTask: function() { console.log("Task start clicked") this.$emit('submit', this.submitData) Loading @@ -86,7 +113,7 @@ export default { }) .catch(error => { if (!error) { error = "Unknown error" error = Error("Unknown error") } console.log("Emitting onError: ", error) this.$emit('error', error) Loading Loading
src/components/controlComponents/settingsComponents/cameraSettings.vue +18 −39 Original line number Diff line number Diff line Loading @@ -26,13 +26,15 @@ <!--Show auto calibrate if default plugin is enabled--> <div v-if="this.$store.state.apiState.plugin.includes('default_camera_calibration')"> <div v-if="isCalibrating"> <progressBar/> </div> <div v-bind:hidden="isCalibrating"> <button type="button" v-on:click="recalibrateConfirm()" class="uk-button uk-button-default uk-form-small uk-float-right uk-margin-small uk-width-1-1">Auto-Calibrate</button> </div> <taskSubmitter v-bind:canTerminate="false" v-bind:requiresConfirmation="true" v-bind:confirmationMessage="'Start recalibration? This may take a while, and the microscope will be locked during this time.'" v-bind:submitURL="recalibrateApiUri" v-bind:submitLabel="'Auto-Calibrate (Task)'" v-on:response="onRecalibrateResponse" v-on:error="onRecalibrateError"> </taskSubmitter> </div> </form> Loading @@ -43,14 +45,14 @@ <script> import axios from 'axios' import progressBar from "../../genericComponents/progressBar" import taskSubmitter from "../../genericComponents/taskSubmitter" // Export main app export default { name: 'microscopeSettings', components: { progressBar taskSubmitter }, data: function () { Loading Loading @@ -95,37 +97,14 @@ export default { this.modalError(error) // Let mixin handle error }) }, recalibrateConfirm: function() { var context = this this.modalConfirm('Start recalibration? This may take a while, and the microscope will be locked during this time.') .then(function() { context.recalibrateRequest() }, function () { console.log('Rejected recalibration.') }) }, recalibrateRequest: function() { // Send move request axios.post(this.recalibrateApiUri) .then(response => { console.log("Task ID: " + response.data.id) this.isCalibrating = true return this.$store.dispatch('pollTask', [response.data.id, null, null]) }) .then(() => { onRecalibrateResponse: function() { this.modalNotify("Finished recalibration.") return new Promise(r => setTimeout(r, 500)) // wait 500ms before updating config, so it's fresh }) .then(() => { return this.$store.dispatch('updateConfig'); }) .then(this.updateInputValues) .catch(error => { }, onRecalibrateError: function(error) { this.modalError(error) // Let mixin handle error }) .finally(() => { this.isCalibrating = false }) } }, Loading
src/components/genericComponents/taskSubmitter.vue +31 −4 Original line number Diff line number Diff line Loading @@ -7,10 +7,10 @@ <div v-else class="indeterminate"></div> </div> <button type="button" v-on:click="terminateTask()" class="uk-button uk-button-danger uk-form-small uk-margin uk-float-right uk-width-1-1">Terminate</button> <button v-if="canTerminate" type="button" v-on:click="terminateTask()" class="uk-button uk-button-danger uk-form-small uk-margin uk-float-right uk-width-1-1">Terminate</button> </div> <button type="button" v-on:click="startTask()" v-bind:hidden="taskRunning" class="uk-button uk-button-primary uk-form-small uk-margin uk-float-right uk-width-1-1">{{ submitLabel }}</button> <button type="button" v-on:click="bootstrapTask()" v-bind:hidden="taskRunning" class="uk-button uk-button-primary uk-form-small uk-margin uk-float-right uk-width-1-1">{{ submitLabel }}</button> </div> </template> Loading @@ -29,7 +29,7 @@ export default { submitData: { type: Object, required: false, default: {} default: () => ({}) }, pollInterval: { type: Number, Loading @@ -46,6 +46,21 @@ export default { required: false, default: "Submit" }, canTerminate: { type: Boolean, required: false, default: true }, requiresConfirmation: { type: Boolean, required: false, default: false }, confirmationMessage: { type: String, required: false, default: "Start task?" } }, data: function () { Loading @@ -64,6 +79,18 @@ export default { }, methods: { bootstrapTask: function() { if (this.requiresConfirmation) { this.modalConfirm(this.confirmationMessage) .then(() => { this.startTask() }, () => {}) } else { this.startTask() } }, startTask: function() { console.log("Task start clicked") this.$emit('submit', this.submitData) Loading @@ -86,7 +113,7 @@ export default { }) .catch(error => { if (!error) { error = "Unknown error" error = Error("Unknown error") } console.log("Emitting onError: ", error) this.$emit('error', error) Loading