fix webcam url in printer farm

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej committed 2021-04-13 22:10:43 +02:00
1 parent 6825f6c39e
commit e814ea5169
9 files changed
+52 -16

No files matched your search

+11 -2
View File
@@ -71,7 +71,7 @@
<webcam-mjpegstreamer :cam-settings="currentWebcam"></webcam-mjpegstreamer>
</template>
<template v-if="'service' in currentWebcam && currentWebcam.service === 'mjpegstreamer-adaptive'">
<webcam-mjpegstreamer-adaptive :cam-settings="currentWebcam"></webcam-mjpegstreamer-adaptive>
<webcam-mjpegstreamer-adaptive :cam-settings="currentWebcam" :printer-url="printerUrl"></webcam-mjpegstreamer-adaptive>
</template>
</div>
<v-card-title class="white--text py-2" style="background-color: rgba(0,0,0,0.3); backdrop-filter: blur(3px);">
@@ -124,6 +124,15 @@
...mapState({
remoteMode: state => state.socket.remoteMode
}),
printerUrl() {
const thisUrl = window.location.href.split("/")
const protocol = thisUrl[0]
let url = protocol+"//"+this.printer.socket.hostname
if (80 !== parseInt(this.printer.socket.webPort)) url += ":"+this.printer.socket.webPort
return url
},
isCurrentPrinter: {
get() {
return this.$store.getters["farm/"+this.printer._namespace+"/isCurrentPrinter"]
@@ -185,7 +194,7 @@
},
changePrinter() {
if (this.remoteMode) this.$store.dispatch('changePrinter', { printer: this.printer._namespace })
else window.location.href = "//"+this.printer.socket.hostname+(parseInt(this.printer.socket.webPort) !== 80 ? ':'+this.printer.socket.webPort : '')
else window.location.href = this.printerUrl
},
reconnectPrinter() {
this.$store.dispatch("farm/"+this.printer._namespace+"/reconnect")
@@ -305,8 +305,8 @@ export default {
},
saveWebcam() {
if (this.dialog.valid) {
if (this.dialog.index) this.$store.dispatch("gui/updateWebcam", this.dialog)
else this.$store.dispatch("gui/addWebcam", this.dialog)
if (this.dialog.index) this.$store.dispatch("gui/updateWebcam", {...this.dialog})
else this.$store.dispatch("gui/addWebcam", {...this.dialog})
this.clearDialog()
}
+12 -4
View File
@@ -27,20 +27,28 @@
data: function() {
return {
isVisible: true,
refresh: Math.ceil(Math.random() * Math.pow(10, 12))
}
},
props: {
camSettings: Object,
printerUrl: {
type: String,
default: null
}
},
created: function () {
},
computed: {
url() {
let basicUrl = this.camSettings.url
const params = new URLSearchParams(basicUrl)
params.set('bypassCache', ""+this.refresh)
return decodeURIComponent(params.toString())
const baseUrl = this.camSettings.url
const hostUrl = new URL(this.printerUrl === null ? document.URL : this.printerUrl)
const url = new URL(baseUrl, hostUrl.origin)
url.searchParams.append('bypassCache', this.refresh.toString())
return decodeURIComponent(url.toString())
},
webcamStyle() {
let transforms = ""
@@ -51,6 +51,10 @@
},
props: {
camSettings: Object,
printerUrl: {
type: String,
default: null
}
},
created: function () {
@@ -101,7 +105,8 @@
},
setUrl() {
const baseUrl = this.camSettings.url
const hostUrl = new URL(document.URL)
const hostUrl = new URL(this.printerUrl === null ? document.URL : this.printerUrl)
const url = new URL(baseUrl, hostUrl.origin)
url.searchParams.append('bypassCache', this.refresh.toString())