Generalise server specified action buttons.
This commit is contained in:
parent
0794d4777f
commit
3651013440
4 changed files with 86 additions and 41 deletions
|
|
@ -791,6 +791,8 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
"Start recalibration? This may take a while, and the microscope "
|
"Start recalibration? This may take a while, and the microscope "
|
||||||
"will be locked during this time."
|
"will be locked during this time."
|
||||||
),
|
),
|
||||||
|
notify_on_success=True,
|
||||||
|
success_message="Finished recalibration.",
|
||||||
),
|
),
|
||||||
action_button_for(
|
action_button_for(
|
||||||
self.auto_expose_from_minimum,
|
self.auto_expose_from_minimum,
|
||||||
|
|
|
||||||
|
|
@ -23,19 +23,33 @@ class ActionButton(BaseModel):
|
||||||
|
|
||||||
thing: str
|
thing: str
|
||||||
"""The Thing "path" for the Thing instance."""
|
"""The Thing "path" for the Thing instance."""
|
||||||
|
|
||||||
action: str
|
action: str
|
||||||
"""The name of the action to be triggered."""
|
"""The name of the action to be triggered."""
|
||||||
|
|
||||||
poll_interval: int = 1
|
poll_interval: int = 1
|
||||||
"""The interval for polling in seconds."""
|
"""The interval for polling in seconds."""
|
||||||
|
|
||||||
submit_label: str = "Submit"
|
submit_label: str = "Submit"
|
||||||
"""The label for the action button."""
|
"""The label for the action button."""
|
||||||
|
|
||||||
can_terminate: bool = True
|
can_terminate: bool = True
|
||||||
"""Specify whether the action can be terminated."""
|
"""Specify whether the action can be terminated."""
|
||||||
|
|
||||||
requires_confirmation: bool = False
|
requires_confirmation: bool = False
|
||||||
"""Specify whether a confirmation modal is needed."""
|
"""Specify whether a confirmation modal is needed."""
|
||||||
|
|
||||||
confirmation_message: str = "Start task?"
|
confirmation_message: str = "Start task?"
|
||||||
"""The message for the confirmation modal."""
|
"""The message for the confirmation modal."""
|
||||||
|
|
||||||
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."""
|
||||||
|
|
||||||
modal_progress: bool = False
|
modal_progress: bool = False
|
||||||
"""Specify whether to show a progress modal."""
|
"""Specify whether to show a progress modal."""
|
||||||
|
|
||||||
|
notify_on_success: bool = False
|
||||||
|
"""Specify whether to a notification on successful completion."""
|
||||||
|
|
||||||
|
success_message: str = "Success!"
|
||||||
|
"""The message to show on successful completion."""
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<template>
|
||||||
|
<action-button
|
||||||
|
:thing="actionData.thing"
|
||||||
|
:action="actionData.action"
|
||||||
|
:poll-interval="actionData.poll_interval"
|
||||||
|
:submit-label="actionData.submit_label"
|
||||||
|
:can-terminate="actionData.can_terminate"
|
||||||
|
:requires-confirmation="actionData.requires_confirmation"
|
||||||
|
:confirmation-message="actionData.confirmation_message"
|
||||||
|
:button-primary="actionData.button_primary"
|
||||||
|
:modal-progress="actionData.modal_progress"
|
||||||
|
@response="actionResponse"
|
||||||
|
@error="modalError"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ActionButton from "./actionButton.vue";
|
||||||
|
|
||||||
|
// Export main app
|
||||||
|
export default {
|
||||||
|
name: "ServerSpecifiedActionButton",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
ActionButton
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
props: {
|
||||||
|
actionData: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
actionResponse: function() {
|
||||||
|
if (this.actionData.notify_on_success) {
|
||||||
|
this.modalNotify(this.actionData.success_message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less"></style>
|
||||||
|
|
@ -1,58 +1,34 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!--Show auto calibrate if default plugin is enabled-->
|
<!--Show calibration actions as specified by the camera.-->
|
||||||
|
<div
|
||||||
<div
|
|
||||||
v-for="(action, index) in secondaryCalibrationActions"
|
v-for="(action, index) in secondaryCalibrationActions"
|
||||||
|
:key="'primary_cal' + index"
|
||||||
class="uk-child-width-expand"
|
class="uk-child-width-expand"
|
||||||
:key = "'primary_cal' + index"
|
|
||||||
>
|
>
|
||||||
<action-button
|
<server-specified-action-button :action-data="action" />
|
||||||
:can-terminate="action.can_terminate"
|
|
||||||
:requires-confirmation="action.requires_confirmation"
|
|
||||||
:thing="action.thing"
|
|
||||||
:action="action.action"
|
|
||||||
:submit-label="action.submit_label"
|
|
||||||
@response="onRecalibrateResponse"
|
|
||||||
@error="modalError"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showExtraSettings">
|
<div v-if="showExtraSettings">
|
||||||
<div
|
<div
|
||||||
v-for="(action, index) in primaryCalibrationActions"
|
v-for="(action, index) in primaryCalibrationActions"
|
||||||
|
:key="'secondary_cal' + index"
|
||||||
class="uk-child-width-expand"
|
class="uk-child-width-expand"
|
||||||
:key = "'secondary_cal' + index"
|
|
||||||
>
|
>
|
||||||
<action-button
|
<server-specified-action-button :action-data="action" />
|
||||||
:can-terminate="action.can_terminate"
|
|
||||||
:requires-confirmation="action.requires_confirmation"
|
|
||||||
:thing="action.thing"
|
|
||||||
:action="action.action"
|
|
||||||
:submit-label="action.submit_label"
|
|
||||||
@response="onRecalibrateResponse"
|
|
||||||
@error="modalError"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ActionButton from "../../../labThingsComponents/actionButton.vue";
|
import ServerSpecifiedActionButton from "../../../labThingsComponents/serverSpecifiedActionButton.vue";
|
||||||
|
|
||||||
// Export main app
|
// Export main app
|
||||||
export default {
|
export default {
|
||||||
name: "CameraCalibrationSettings",
|
name: "CameraCalibrationSettings",
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ActionButton
|
ServerSpecifiedActionButton
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
primaryCalibrationActions: [],
|
|
||||||
secondaryCalibrationActions: []
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -67,6 +43,13 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
primaryCalibrationActions: [],
|
||||||
|
secondaryCalibrationActions: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
actions() {
|
actions() {
|
||||||
return this.$store.getters["wot/thingDescription"]("camera").actions;
|
return this.$store.getters["wot/thingDescription"]("camera").actions;
|
||||||
|
|
@ -74,14 +57,14 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
this.primaryCalibrationActions = await this.readThingProperty("camera", "primary_calibration_actions");
|
this.primaryCalibrationActions = await this.readThingProperty(
|
||||||
this.secondaryCalibrationActions = await this.readThingProperty("camera", "secondary_calibration_actions");
|
"camera",
|
||||||
},
|
"primary_calibration_actions"
|
||||||
|
);
|
||||||
methods: {
|
this.secondaryCalibrationActions = await this.readThingProperty(
|
||||||
onRecalibrateResponse: function() {
|
"camera",
|
||||||
this.modalNotify("Finished recalibration.");
|
"secondary_calibration_actions"
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue