Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions src/components/panels/FarmPrinterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</v-list-item-content>
</v-list-item>
<v-list-item
v-for="webcam of printer_webcams"
v-for="webcam of supportedPrinterWebcams"
:key="webcam.index"
link
@click="currentCamId = webcam.id">
Expand All @@ -45,21 +45,28 @@
<div>
<v-img ref="imageDiv" :height="imageHeight" :src="printer_image" class="d-flex align-end">
<div
v-if="printer.socket.isConnected && currentCamId !== 'off' && currentWebcam"
v-if="
printer.socket.isConnected &&
currentCamId !== 'off' &&
currentWebcam &&
'service' in currentWebcam
"
class="webcamContainer">
<template v-if="'service' in currentWebcam && currentWebcam.service === 'mjpegstreamer'">
<webcam-mjpegstreamer
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer>
</template>
<template
v-if="'service' in currentWebcam && currentWebcam.service === 'mjpegstreamer-adaptive'">
<webcam-mjpegstreamer-adaptive
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer-adaptive>
</template>
<webcam-mjpegstreamer
v-if="currentWebcam.service === 'mjpegstreamer'"
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer>
<webcam-mjpegstreamer-adaptive
v-else-if="currentWebcam.service === 'mjpegstreamer-adaptive'"
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-mjpegstreamer-adaptive>
<webcam-uv4l-mjpeg
v-else-if="currentWebcam.service === 'uv4l-mjpeg'"
:cam-settings="currentWebcam"
:printer-url="printerUrl"
:show-fps="false"></webcam-uv4l-mjpeg>
</div>
<v-card-title
class="white--text py-2"
Expand Down Expand Up @@ -125,16 +132,19 @@ import BaseMixin from '@/components/mixins/base'
import { FarmPrinterState } from '@/store/farm/printer/types'
import Mjpegstreamer from '@/components/webcams/Mjpegstreamer.vue'
import MjpegstreamerAdaptive from '@/components/webcams/MjpegstreamerAdaptive.vue'
import Uv4lMjpeg from '@/components/webcams/Uv4lMjpeg.vue'
import MainsailLogo from '@/components/ui/MainsailLogo.vue'
import Panel from '@/components/ui/Panel.vue'
import { mdiPrinter3d, mdiWebcam, mdiMenuDown, mdiWebcamOff, mdiFileOutline } from '@mdi/js'
import { Debounce } from 'vue-debounce-decorator'
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'

@Component({
components: {
Panel,
'webcam-mjpegstreamer': Mjpegstreamer,
'webcam-mjpegstreamer-adaptive': MjpegstreamerAdaptive,
'webcam-uv4l-mjpeg': Uv4lMjpeg,
'mainsail-logo': MainsailLogo,
},
})
Expand Down Expand Up @@ -207,13 +217,19 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin) {
}

get showWebcamSwitch() {
return this.printer.socket.isConnected && this.printer_webcams.length > 0
return this.printer.socket.isConnected && this.supportedPrinterWebcams.length > 0
}

get printer_webcams() {
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() {
const currentCam = this.printer_webcams.find((webcam: any) => webcam.id === this.currentCamId)
if (currentCam) return currentCam
Expand Down