Web app controls for background detection

There are now buttons to set, and check, the background
detect plugin.
This commit is contained in:
Richard Bowman 2024-01-03 21:36:25 +00:00
parent 0083231b85
commit 778da73a70
3 changed files with 113 additions and 2 deletions

View file

@ -0,0 +1,81 @@
<template>
<div class="uk-padding-small">
<div v-show="!thingAvailable" class="ui-alert-error" uk-alert>
The background detect Thing seems to be missing or incompatible.
</div>
<div v-show="thingAvailable">
<div class="uk-margin">
<taskSubmitter
:submit-url="setBackgroundUri"
submit-label="Set background"
:can-terminate="false"
:poll-interval="0.1"
/>
</div>
<div class="uk-margin">
<propertyControl
thing-name="background_detect"
property-name="tolerance"
label="Tolerance"
/>
</div>
<div class="uk-margin">
<taskSubmitter
:submit-url="backgroundFractionUri"
submit-label="Check current image"
:can-terminate="false"
:poll-interval="0.1"
@response="alertBackgroundFraction"
/>
</div>
</div>
</div>
</template>
<script>
import taskSubmitter from "../../genericComponents/taskSubmitter";
import propertyControl from "../../labThingsComponents/propertyControl.vue";
export default {
components: {
taskSubmitter,
propertyControl
},
data: function() {
return {
};
},
computed: {
backgroundFractionUri() {
return this.thingActionUrl("background_detect", "background_fraction");
},
setBackgroundUri() {
return this.thingActionUrl("background_detect", "set_background");
}
},
methods: {
alertBackgroundFraction(r) {
let fraction = r.output
let percentage = (fraction * 100).toFixed(1)
this.modalNotify(`Current image is ${percentage}% background.`)
}
}
};
</script>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto;
grid-column-gap: 10px;
}
.warning {
color: #c11;
font-weight: bold;
text-align: center;
}
</style>