Prevent calibration navigation during actions

This commit is contained in:
Julian Stirling 2026-06-30 10:54:25 +01:00
parent c5867b02e9
commit 6148e49282
4 changed files with 50 additions and 7 deletions

View file

@ -12,6 +12,7 @@
:modal-progress="actionData.modal_progress" :modal-progress="actionData.modal_progress"
:stream-with-modal="actionData.stream_with_modal" :stream-with-modal="actionData.stream_with_modal"
:is-broken="actionData.broken" :is-broken="actionData.broken"
@task-started="actionStarted"
@response="actionResponse" @response="actionResponse"
@error="modalError" @error="modalError"
@finished="actionFinished" @finished="actionFinished"
@ -36,7 +37,7 @@ export default {
}, },
}, },
emits: ["response", "finished", "requestUpdate"], emits: ["started", "response", "finished", "requestUpdate"],
methods: { methods: {
/** /**
@ -58,6 +59,14 @@ export default {
this.$emit("response", response); this.$emit("response", response);
} }
}, },
/**
* Runs when the ActionButton's action starts
*
* This forwards the event to the parent
*/
actionStarted: function () {
this.$emit("started");
},
/** /**
* Runs when the ActionButton's action finishes in any way (error, cancel, * Runs when the ActionButton's action finishes in any way (error, cancel,
* completion). * completion).

View file

@ -28,17 +28,24 @@ gets very confusing.
v-if="currentStep" v-if="currentStep"
:key="stepIndex" :key="stepIndex"
@awaiting-user="handleAwaitingUser" @awaiting-user="handleAwaitingUser"
@prevent-navigation="handlePreventNavigation"
/> />
<p class="uk-text-right"> <p class="uk-text-right">
<button <button
v-if="showBackButton" v-if="showBackButton"
class="uk-button uk-button-default" class="uk-button uk-button-default"
:class="{ 'uk-button-disabled': preventNavigation, 'disabled-cursor': preventNavigation }"
type="button" type="button"
@click="previousStep" @click="previousStep"
> >
Back Back
</button> </button>
<button class="uk-button uk-button-primary uk-margin-left" type="button" @click="nextStep"> <button
class="uk-button uk-button-primary uk-margin-left"
:class="{ 'uk-button-disabled': preventNavigation, 'disabled-cursor': preventNavigation }"
type="button"
@click="nextStep"
>
{{ nextButtonText }} {{ nextButtonText }}
</button> </button>
</p> </p>
@ -72,6 +79,7 @@ export default {
return { return {
stepIndex: this.startOnLast ? this.steps.length - 1 : 0, stepIndex: this.startOnLast ? this.steps.length - 1 : 0,
stepAwaitingUser: false, stepAwaitingUser: false,
preventNavigation: false,
}; };
}, },
@ -96,6 +104,7 @@ export default {
* Move to the previous step in this task, or the previous task if first step. * Move to the previous step in this task, or the previous task if first step.
*/ */
previousStep: function () { previousStep: function () {
if (this.preventNavigation) return;
this.stepAwaitingUser = false; this.stepAwaitingUser = false;
if (this.stepIndex > 0) { if (this.stepIndex > 0) {
this.stepIndex = this.stepIndex - 1; this.stepIndex = this.stepIndex - 1;
@ -108,6 +117,7 @@ export default {
* Move to the next step in this task, or the next task if final step. * Move to the next step in this task, or the next task if final step.
*/ */
nextStep: function () { nextStep: function () {
if (this.preventNavigation) return;
this.stepAwaitingUser = false; this.stepAwaitingUser = false;
if (this.stepIndex < this.steps.length - 1) { if (this.stepIndex < this.steps.length - 1) {
this.stepIndex = this.stepIndex + 1; this.stepIndex = this.stepIndex + 1;
@ -119,6 +129,14 @@ export default {
handleAwaitingUser(isAwaiting) { handleAwaitingUser(isAwaiting) {
this.stepAwaitingUser = isAwaiting; this.stepAwaitingUser = isAwaiting;
}, },
handlePreventNavigation(blocked) {
this.preventNavigation = blocked;
},
}, },
}; };
</script> </script>
<style lang="less" scoped>
.disabled-cursor {
cursor: not-allowed !important ;
}
</style>

View file

@ -12,7 +12,8 @@
<cameraCalibrationSettings <cameraCalibrationSettings
:show-extra-settings="false" :show-extra-settings="false"
:camera-uri="cameraUri" :camera-uri="cameraUri"
@action-finished="checkCalibrationState" @action-started="onActionStart"
@action-finished="onActionComplete"
/> />
</div> </div>
</template> </template>
@ -33,7 +34,7 @@ export default {
cameraCalibrationSettings, cameraCalibrationSettings,
}, },
emits: ["awaiting-user"], emits: ["prevent-navigation", "awaiting-user"],
computed: { computed: {
...mapState(useSettingsStore, ["baseUri"]), ...mapState(useSettingsStore, ["baseUri"]),
@ -47,6 +48,13 @@ export default {
}, },
methods: { methods: {
onActionStart() {
this.$emit("prevent-navigation", true);
},
async onActionComplete() {
await this.checkCalibrationState();
this.$emit("prevent-navigation", false);
},
async checkCalibrationState() { async checkCalibrationState() {
const needsCal = await this.readThingProperty("camera", "calibration_required"); const needsCal = await this.readThingProperty("camera", "calibration_required");
this.$emit("awaiting-user", needsCal); this.$emit("awaiting-user", needsCal);

View file

@ -6,7 +6,11 @@
:key="'primary_cal' + index" :key="'primary_cal' + index"
class="uk-child-width-expand" class="uk-child-width-expand"
> >
<server-specified-action-button :action-data="action" @finished="$emit('actionFinished')" /> <server-specified-action-button
:action-data="action"
@started="$emit('actionStarted')"
@finished="$emit('actionFinished')"
/>
</div> </div>
<div v-if="showExtraSettings"> <div v-if="showExtraSettings">
<div <div
@ -14,7 +18,11 @@
:key="'secondary_cal' + index" :key="'secondary_cal' + index"
class="uk-child-width-expand" class="uk-child-width-expand"
> >
<server-specified-action-button :action-data="action" @finished="$emit('actionFinished')" /> <server-specified-action-button
:action-data="action"
@started="$emit('actionStarted')"
@finished="$emit('actionFinished')"
/>
</div> </div>
</div> </div>
</div> </div>
@ -43,7 +51,7 @@ export default {
}, },
}, },
emits: ["actionFinished"], emits: ["actionStarted", "actionFinished"],
data() { data() {
return { return {