Reintroduce recactive button state for background detect

This commit is contained in:
Julian Stirling 2026-03-08 16:53:58 +00:00
parent 4da05b1869
commit eccf26851e
6 changed files with 31 additions and 4 deletions

View file

@ -625,12 +625,14 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
can_terminate=False, can_terminate=False,
notify_on_success=True, notify_on_success=True,
success_message="Background image has been updated", success_message="Background image has been updated",
update_interface_on_response=True,
) )
check_bg_button = action_button_for( check_bg_button = action_button_for(
self, self,
"check_background", "check_background",
poll_interval=0.1, poll_interval=0.1,
submit_label="Check Current Image", submit_label="Check Current Image",
disabled=not self._background_detector.ready,
can_terminate=False, can_terminate=False,
notify_on_success=True, notify_on_success=True,
response_is_success_message=True, response_is_success_message=True,

View file

@ -158,6 +158,9 @@ class ActionButton(BaseModel):
button_primary: bool = True button_primary: bool = True
"""Specify whether the button is styled as a primary button.""" """Specify whether the button is styled as a primary button."""
disabled: bool = False
"""Specify whether the button is disabled."""
modal_progress: bool = False modal_progress: bool = False
"""Specify whether to show a progress modal.""" """Specify whether to show a progress modal."""
@ -180,6 +183,12 @@ class ActionButton(BaseModel):
success_message: str = "Success!" success_message: str = "Success!"
"""The message to show on successful completion.""" """The message to show on successful completion."""
update_interface_on_response: bool = False
"""If True the action button emits a requestUpdate signal when completed.
Downstream components can subscribe to this and request an update.
"""
def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> ActionButton: def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> ActionButton:
"""Create a ActionButton data for the specified Thing Action. """Create a ActionButton data for the specified Thing Action.

View file

@ -322,6 +322,9 @@ export default {
} else if (response.data.status == "cancelled") { } else if (response.data.status == "cancelled") {
this.$emit("cancelled", response.data); this.$emit("cancelled", response.data);
this.modalNotify(`The action '${this.submitLabel}' was cancelled.`); this.modalNotify(`The action '${this.submitLabel}' was cancelled.`);
} else if (response.data.status == "error") {
const err_msg = this.log?.[0]?.message ?? "Unknown error";
this.$emit("error", err_msg);
} }
} }
this.taskUrl = null; this.taskUrl = null;

View file

@ -8,6 +8,7 @@
:requires-confirmation="actionData.requires_confirmation" :requires-confirmation="actionData.requires_confirmation"
:confirmation-message="actionData.confirmation_message" :confirmation-message="actionData.confirmation_message"
:button-primary="actionData.button_primary" :button-primary="actionData.button_primary"
:is-disabled="actionData.disabled"
:modal-progress="actionData.modal_progress" :modal-progress="actionData.modal_progress"
:stream-with-modal="actionData.stream_with_modal" :stream-with-modal="actionData.stream_with_modal"
@response="actionResponse" @response="actionResponse"
@ -34,7 +35,7 @@ export default {
}, },
}, },
emits: ["response", "finished"], emits: ["response", "finished", "requestUpdate"],
methods: { methods: {
/** /**
@ -50,6 +51,9 @@ export default {
} else { } else {
this.modalNotify(this.actionData.success_message); this.modalNotify(this.actionData.success_message);
} }
if (this.actionData.update_interface_on_response) {
this.$emit("requestUpdate");
}
this.$emit("response", response); this.$emit("response", response);
} }
}, },

View file

@ -10,12 +10,19 @@
<server-specified-action-button <server-specified-action-button
v-else-if="element.element_type === 'action_button'" v-else-if="element.element_type === 'action_button'"
:action-data="element" :action-data="element"
@request-update="$emit('requestUpdate')"
/> />
<simple-accordion v-else-if="element.element_type === 'accordion'" :title="element.title"> <simple-accordion v-else-if="element.element_type === 'accordion'" :title="element.title">
<server-specified-interface :elements="element.children" /> <server-specified-interface
:elements="element.children"
@request-update="$emit('requestUpdate')"
/>
</simple-accordion> </simple-accordion>
<div v-else-if="element.element_type === 'container'" :class="element.css_class"> <div v-else-if="element.element_type === 'container'" :class="element.css_class">
<server-specified-interface :elements="element.children" /> <server-specified-interface
:elements="element.children"
@request-update="$emit('requestUpdate')"
/>
</div> </div>
</div> </div>
</template> </template>
@ -41,6 +48,8 @@ export default {
required: true, required: true,
}, },
}, },
emits: ["requestUpdate"],
}; };
</script> </script>

View file

@ -16,7 +16,7 @@
</option> </option>
</select> </select>
</div> </div>
<server-specified-interface :elements="workflowSettings" /> <server-specified-interface :elements="workflowSettings" @request-update="readSettings" />
<ul uk-accordion="multiple: true"> <ul uk-accordion="multiple: true">
<li class="uk-open"> <li class="uk-open">
<a class="uk-accordion-title" href="#">Stitching Settings</a> <a class="uk-accordion-title" href="#">Stitching Settings</a>