Display background detector settings built automatically from schema
This commit is contained in:
parent
d376eee5d5
commit
92d15d921b
3 changed files with 20 additions and 6 deletions
|
|
@ -32,8 +32,9 @@ class BackgroundDetectorStatus(BaseModel):
|
||||||
``ready`` is used in case more complex methods are added in the future, which
|
``ready`` is used in case more complex methods are added in the future, which
|
||||||
need different initialisation.
|
need different initialisation.
|
||||||
"""
|
"""
|
||||||
settings: BaseModel
|
settings: dict[str, Any]
|
||||||
"""The settings for this this background detect Algorithm"""
|
"""The settings for this this background detect Algorithm. These are a dictionary
|
||||||
|
dumped from the base model."""
|
||||||
|
|
||||||
# Setting schema is a dict until LabThings FastAPI issue #154 is fixed and
|
# Setting schema is a dict until LabThings FastAPI issue #154 is fixed and
|
||||||
# DataSchema can be used directly. For now `model_dump()` must be used to dump schema
|
# DataSchema can be used directly. For now `model_dump()` must be used to dump schema
|
||||||
|
|
@ -63,7 +64,7 @@ class BackgroundDetectAlgorithm:
|
||||||
"""The status information needed for the GUI. Read only."""
|
"""The status information needed for the GUI. Read only."""
|
||||||
return BackgroundDetectorStatus(
|
return BackgroundDetectorStatus(
|
||||||
ready=self.background_data is not None,
|
ready=self.background_data is not None,
|
||||||
settings=self.settings,
|
settings=self.settings.model_dump(),
|
||||||
# Dump model with `model_dump()` for reason explained when defining
|
# Dump model with `model_dump()` for reason explained when defining
|
||||||
# BackgroundDetectorStatus
|
# BackgroundDetectorStatus
|
||||||
settings_schema=type_to_dataschema(self.settings_data_model).model_dump(),
|
settings_schema=type_to_dataschema(self.settings_data_model).model_dump(),
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ export default {
|
||||||
},
|
},
|
||||||
writeProperty: async function(requestedValue) {
|
writeProperty: async function(requestedValue) {
|
||||||
try {
|
try {
|
||||||
console.log(requestedValue);
|
|
||||||
this.value=requestedValue;
|
this.value=requestedValue;
|
||||||
await this.writeThingProperty(
|
await this.writeThingProperty(
|
||||||
this.thingName,
|
this.thingName,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,12 @@
|
||||||
<li>
|
<li>
|
||||||
<a class="uk-accordion-title" href="#">Settings</a>
|
<a class="uk-accordion-title" href="#">Settings</a>
|
||||||
<div class="uk-accordion-content">
|
<div class="uk-accordion-content">
|
||||||
<p> TODO!</p>
|
<input-from-schema
|
||||||
|
v-if="backgroundDetectorStatus"
|
||||||
|
v-model="backgroundDetectorStatus.settings"
|
||||||
|
:data-schema="backgroundDetectorStatus.settings_schema"
|
||||||
|
label=""
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -26,7 +31,7 @@
|
||||||
thing="camera"
|
thing="camera"
|
||||||
action="image_is_sample"
|
action="image_is_sample"
|
||||||
submit-label="Check Current Image"
|
submit-label="Check Current Image"
|
||||||
:isDisabled="!backgroundDetectorStatus.ready"
|
:isDisabled="!ready"
|
||||||
:can-terminate="false"
|
:can-terminate="false"
|
||||||
:poll-interval="0.1"
|
:poll-interval="0.1"
|
||||||
@response="alertImageLabel"
|
@response="alertImageLabel"
|
||||||
|
|
@ -39,10 +44,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ActionButton from "../../labThingsComponents/actionButton.vue";
|
import ActionButton from "../../labThingsComponents/actionButton.vue";
|
||||||
|
import InputFromSchema from "../../labThingsComponents/inputFromSchema.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ActionButton,
|
ActionButton,
|
||||||
|
InputFromSchema
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -51,6 +58,13 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
ready() {
|
||||||
|
const status = this.backgroundDetectorStatus;
|
||||||
|
return status && status.ready === true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
alertBackgroundSet() {
|
alertBackgroundSet() {
|
||||||
this.modalNotify(`Background image has been updated`);
|
this.modalNotify(`Background image has been updated`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue