fix: add u4vl-mjpeg to printfarm & only display supported modes (#831)

This commit is contained in:
Stefan Dej 2022-05-21 13:35:06 +02:00 committed by GitHub
parent bc841609ba
commit 5cbcebb771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
<v-list-item <v-list-item
v-for="webcam of printer_webcams" v-for="webcam of supportedPrinterWebcams"
:key="webcam.index" :key="webcam.index"
link link
@click="currentCamId = webcam.id"> @click="currentCamId = webcam.id">
@ -45,21 +45,28 @@
<div> <div>
<v-img ref="imageDiv" :height="imageHeight" :src="printer_image" class="d-flex align-end"> <v-img ref="imageDiv" :height="imageHeight" :src="printer_image" class="d-flex align-end">
<div <div
v-if="printer.socket.isConnected && currentCamId !== 'off' && currentWebcam" v-if="
printer.socket.isConnected &&
currentCamId !== 'off' &&
currentWebcam &&
'service' in currentWebcam
"
class="webcamContainer"> class="webcamContainer">
<template v-if="'service' in currentWebcam && currentWebcam.service === 'mjpegstreamer'">
<webcam-mjpegstreamer <webcam-mjpegstreamer
v-if="currentWebcam.service === 'mjpegstreamer'"
:cam-settings="currentWebcam" :cam-settings="currentWebcam"
:printer-url="printerUrl" :printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer> :show-fps="false"></webcam-mjpegstreamer>
</template>
<template
v-if="'service' in currentWebcam && currentWebcam.service === 'mjpegstreamer-adaptive'">
<webcam-mjpegstreamer-adaptive <webcam-mjpegstreamer-adaptive
v-else-if="currentWebcam.service === 'mjpegstreamer-adaptive'"
:cam-settings="currentWebcam" :cam-settings="currentWebcam"
:printer-url="printerUrl" :printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer-adaptive> :show-fps="false"></webcam-mjpegstreamer-adaptive>
</template> <webcam-uv4l-mjpeg
v-else-if="currentWebcam.service === 'uv4l-mjpeg'"
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-uv4l-mjpeg>
</div> </div>
<v-card-title <v-card-title
class="white--text py-2" class="white--text py-2"
@ -125,16 +132,19 @@ import BaseMixin from '@/components/mixins/base'
import { FarmPrinterState } from '@/store/farm/printer/types' import { FarmPrinterState } from '@/store/farm/printer/types'
import Mjpegstreamer from '@/components/webcams/Mjpegstreamer.vue' import Mjpegstreamer from '@/components/webcams/Mjpegstreamer.vue'
import MjpegstreamerAdaptive from '@/components/webcams/MjpegstreamerAdaptive.vue' import MjpegstreamerAdaptive from '@/components/webcams/MjpegstreamerAdaptive.vue'
import Uv4lMjpeg from '@/components/webcams/Uv4lMjpeg.vue'
import MainsailLogo from '@/components/ui/MainsailLogo.vue' import MainsailLogo from '@/components/ui/MainsailLogo.vue'
import Panel from '@/components/ui/Panel.vue' import Panel from '@/components/ui/Panel.vue'
import { mdiPrinter3d, mdiWebcam, mdiMenuDown, mdiWebcamOff, mdiFileOutline } from '@mdi/js' import { mdiPrinter3d, mdiWebcam, mdiMenuDown, mdiWebcamOff, mdiFileOutline } from '@mdi/js'
import { Debounce } from 'vue-debounce-decorator' import { Debounce } from 'vue-debounce-decorator'
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'
@Component({ @Component({
components: { components: {
Panel, Panel,
'webcam-mjpegstreamer': Mjpegstreamer, 'webcam-mjpegstreamer': Mjpegstreamer,
'webcam-mjpegstreamer-adaptive': MjpegstreamerAdaptive, 'webcam-mjpegstreamer-adaptive': MjpegstreamerAdaptive,
'webcam-uv4l-mjpeg': Uv4lMjpeg,
'mainsail-logo': MainsailLogo, 'mainsail-logo': MainsailLogo,
}, },
}) })
@ -207,13 +217,19 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin) {
} }
get showWebcamSwitch() { get showWebcamSwitch() {
return this.printer.socket.isConnected && this.printer_webcams.length > 0 return this.printer.socket.isConnected && this.supportedPrinterWebcams.length > 0
} }
get printer_webcams() { get printer_webcams() {
return this.$store.getters['farm/' + this.printer._namespace + '/getPrinterWebcams'] return this.$store.getters['farm/' + this.printer._namespace + '/getPrinterWebcams']
} }
get supportedPrinterWebcams() {
return this.printer_webcams.filter((webcam: GuiWebcamStateWebcam) =>
['mjpegstreamer', 'mjpegstreamer-adaptive', 'uv4l-mjpeg'].includes(webcam.service)
)
}
get currentWebcam() { get currentWebcam() {
const currentCam = this.printer_webcams.find((webcam: any) => webcam.id === this.currentCamId) const currentCam = this.printer_webcams.find((webcam: any) => webcam.id === this.currentCamId)
if (currentCam) return currentCam if (currentCam) return currentCam