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

refactor: use moonraker webcam api instead of direct database access #1445

Merged
merged 26 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f3a7000
refactor: use moonraker webcam api instead of direct database access
meteyou Jun 24, 2023
e6b7495
Merge branch 'develop' into refactor/webcam-api
meteyou Jun 24, 2023
e69b34b
refactor: initStore of gui/webcams
meteyou Jun 25, 2023
bdd1518
chore: update moonraker min version
meteyou Jun 25, 2023
fc94ba0
refactor: add notify_webcams_changed
meteyou Jun 25, 2023
7326a9f
refactor: update GuiWebcamStateWebcam type
meteyou Jun 25, 2023
2098ae3
refactor: update webcam settings to moonraker API
meteyou Jun 25, 2023
edb34d9
refactor: update MjpegstreamerAdaptive.vue to moonraker webcam API
meteyou Jun 25, 2023
10650b2
refactor: update Hlsstreamer.vue to moonraker webcam API
meteyou Jun 25, 2023
f389c5b
refactor: update Ipstreamer.vue to moonraker webcam API
meteyou Jun 25, 2023
720136e
refactor: update JanusStreamer.vue to moonraker webcam API
meteyou Jun 25, 2023
3bf1e4b
refactor: update JMuxerStream.vue to moonraker webcam API
meteyou Jun 25, 2023
f4217a9
refactor: update Mjpegstreamer.vue to moonraker webcam API
meteyou Jun 25, 2023
844fedf
refactor: update Uv4lMjpeg.vue to moonraker webcam API
meteyou Jun 25, 2023
419999a
refactor: update WebcamWrapper.vue to moonraker webcam API
meteyou Jun 25, 2023
1701c2c
refactor: update WebrtcCameraStreamer.vue to moonraker webcam API
meteyou Jun 25, 2023
4ece006
refactor: update WebrtcMediaMTX.vue to moonraker webcam API
meteyou Jun 25, 2023
c5087fd
refactor: only allow changing settings if they are from the database
meteyou Jun 25, 2023
8573b3e
refactor: use name instead of id to store the current cam
meteyou Jun 25, 2023
4cd5415
refactor: The unused import `GuiWebcamStateWebcam` was removed from `…
meteyou Jun 28, 2023
e71ba65
refactor: fix WebcamPanel and use webcam.name instead of webcam.id
meteyou Jun 28, 2023
8a349ea
refactor: fix FarmPrinterPanel.vue
meteyou Jun 28, 2023
cb60dc2
refactor: remove DB webcams from backup/restore list
meteyou Jun 30, 2023
faf2717
refactor: remove DB webcams from backup/restore list
meteyou Jun 30, 2023
7959cde
locale: remove DbWebcams
meteyou Jun 30, 2023
e586141
refactor: removed unused attribute in getWebcam getter
meteyou Jul 13, 2023
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
49 changes: 29 additions & 20 deletions src/components/panels/FarmPrinterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<panel
:icon="mdiPrinter3d"
:title="printer_name"
:card-class="
'farmprinter-panel ' +
(!printer.socket.isConnected && !printer.socket.isConnecting ? 'disabledPrinter' : '')
"
card-class="farmprinter-panel"
:class="panelClass"
:loading="printer.socket.isConnecting"
:toolbar-color="isCurrentPrinter ? 'primary' : ''">
<template #buttons>
Expand All @@ -17,7 +15,7 @@
</v-btn>
</template>
<v-list dense class="py-0">
<v-list-item link @click="currentCamId = 'off'">
<v-list-item link @click="currentCamName = 'off'">
<v-list-item-icon class="mr-2">
<v-icon small class="mt-1">{{ mdiWebcamOff }}</v-icon>
</v-list-item-icon>
Expand All @@ -27,9 +25,9 @@
</v-list-item>
<v-list-item
v-for="webcam of printer_webcams"
:key="webcam.index"
:key="webcam.name"
link
@click="currentCamId = webcam.id">
@click="currentCamName = webcam.name">
<v-list-item-icon class="mr-2">
<v-icon small class="mt-1">{{ convertWebcamIcon(webcam.icon) }}</v-icon>
</v-list-item-icon>
Expand All @@ -47,7 +45,7 @@
<div
v-if="
printer.socket.isConnected &&
currentCamId !== 'off' &&
currentCamName !== 'off' &&
currentWebcam &&
'service' in currentWebcam
"
Expand Down Expand Up @@ -122,6 +120,7 @@ import { mdiPrinter3d, mdiWebcam, mdiMenuDown, mdiWebcamOff, mdiFileOutline } fr
import { Debounce } from 'vue-debounce-decorator'
import WebcamMixin from '@/components/mixins/webcam'
import WebcamWrapper from '@/components/webcams/WebcamWrapper.vue'
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'

@Component({
components: {
Expand Down Expand Up @@ -156,12 +155,12 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin, WebcamMixin) {
return this.$store.getters['farm/' + this.printer._namespace + '/isCurrentPrinter']
}

get currentCamId() {
return this.$store.getters['farm/' + this.printer._namespace + '/getSetting']('currentCamId', 'off')
get currentCamName() {
return this.$store.getters['farm/' + this.printer._namespace + '/getSetting']('currentCamName', 'off')
}

set currentCamId(newVal) {
this.$store.dispatch('farm/' + this.printer._namespace + '/setSettings', { currentCamId: newVal })
set currentCamName(newVal) {
this.$store.dispatch('farm/' + this.printer._namespace + '/setSettings', { currentCamName: newVal })
}

get printer_name() {
Expand Down Expand Up @@ -199,18 +198,30 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin, WebcamMixin) {
}

get showWebcamSwitch() {
return this.printer.socket.isConnected && this.printer_webcams.length > 0
if (this.printer_webcams.length == 0) return false

return this.printer.socket.isConnected
}

get printer_webcams() {
get printer_webcams(): GuiWebcamStateWebcam[] {
return this.$store.getters['farm/' + this.printer._namespace + '/getPrinterWebcams']
}

get currentWebcam() {
const currentCam = this.printer_webcams.find((webcam: any) => webcam.id === this.currentCamId)
get currentWebcam(): GuiWebcamStateWebcam | null {
const currentCam = this.printer_webcams?.find(
(webcam: GuiWebcamStateWebcam) => webcam.name === this.currentCamName
)
if (currentCam) return currentCam

return false
return null
}

get panelClass(): string[] {
let output = []

if (!this.printer.socket.isConnected && !this.printer.socket.isConnecting) output.push('disabledPrinter')

return output
}

clickPrinter() {
Expand Down Expand Up @@ -268,10 +279,8 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin, WebcamMixin) {
.v-overlay {
top: 48px;
}
</style>

<style>
.farmprinter-panel {
::v-deep .farmprinter-panel {
position: relative;
}
</style>
11 changes: 6 additions & 5 deletions src/components/panels/WebcamPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<v-list-item-title>{{ $t('Panels.WebcamPanel.All') }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-for="webcam of webcams" :key="webcam.id" link @click="currentCamId = webcam.id">
<v-list-item v-for="webcam of webcams" :key="webcam.name" link @click="currentCamId = webcam.name">
<v-list-item-icon class="mr-2">
<v-icon small class="mt-1">{{ convertWebcamIcon(webcam.icon) }}</v-icon>
</v-list-item-icon>
Expand Down Expand Up @@ -77,13 +77,14 @@ export default class WebcamPanel extends Mixins(BaseMixin, WebcamMixin) {
return this.$store.getters['gui/webcams/getWebcams']
}

// id changed to name with the refactoring of using moonraker webcam API
get currentCamId(): string {
if (this.webcams.length === 1) return this.webcams[0].id ?? 'all'
if (this.webcams.length === 1) return this.webcams[0].name ?? 'all'

let currentCamId = this.$store.state.gui.view.webcam.currentCam[this.currentPage ?? ''] ?? 'all'
if (this.webcams.findIndex((webcam: GuiWebcamStateWebcam) => webcam.id === currentCamId) !== -1)
if (this.webcams.findIndex((webcam: GuiWebcamStateWebcam) => webcam.name === currentCamId) !== -1)
return currentCamId
else if (currentCamId !== undefined && this.webcams.length === 1) return this.webcams[0].id ?? ''
else if (currentCamId !== undefined && this.webcams.length === 1) return this.webcams[0].name ?? ''
else return 'all'
}

Expand All @@ -92,7 +93,7 @@ export default class WebcamPanel extends Mixins(BaseMixin, WebcamMixin) {
}

get currentCam(): any {
const cam = this.webcams.find((cam: GuiWebcamStateWebcam) => cam.id === this.currentCamId)
const cam = this.webcams.find((cam: GuiWebcamStateWebcam) => cam.name === this.currentCamId)

return (
cam ?? {
Expand Down
16 changes: 0 additions & 16 deletions src/components/settings/SettingsGeneralTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@
hide-details
class="mt-0"
@change="changeNamespace('timelapse')"></v-checkbox>
<v-checkbox
v-if="availableNamespaces.includes('webcams')"
:label="$t('Settings.GeneralTab.DbWebcams')"
hide-details
class="mt-0"
@change="changeNamespace('webcams')"></v-checkbox>
</v-col>
</v-row>
<v-row>
Expand Down Expand Up @@ -180,12 +174,6 @@
hide-details
class="mt-0"
@change="changeNamespace('timelapse')"></v-checkbox>
<v-checkbox
v-if="availableNamespaces.includes('webcams')"
:label="$t('Settings.GeneralTab.DbWebcams')"
hide-details
class="mt-0"
@change="changeNamespace('webcams')"></v-checkbox>
<v-checkbox
v-if="moonrakerComponents.includes('history')"
:label="$t('Settings.GeneralTab.DbHistoryJobs')"
Expand Down Expand Up @@ -345,10 +333,6 @@ export default class SettingsGeneralTab extends Mixins(BaseMixin) {
name: 'view',
label: this.$t('Settings.GeneralTab.DbView').toString(),
},
{
name: 'webcams',
label: this.$t('Settings.WebcamsTab.Webcams').toString(),
},
]
}

Expand Down
Loading