1818
1919 <v-spacer />
2020
21- <!-- TODO uncomment when QR scanning is available
2221 <v-menu
2322 v-if =" cameras.length > 1"
2423 v-model =" cameraSelectionMenuOpen"
7473 {{ $t('app.spoolman.btn.scan_code') }}
7574 </template >
7675 </app-btn >
77- -->
7876
7977 <v-text-field
8078 v-model =" search"
130128 </div >
131129 </div >
132130 </td >
131+ <td >{{ item.id }}</td >
133132 <td >{{ item.filament.material }}</td >
134133 <td >{{ item.location }}</td >
135134 <td >{{ item.comment }}</td >
@@ -196,6 +195,7 @@ import { Spool } from '@/store/spoolman/types'
196195import BrowserMixin from ' @/mixins/browser'
197196import QRReader from ' @/components/widgets/spoolman/QRReader.vue'
198197import { CameraConfig } from ' @/store/cameras/types'
198+ import QrScanner from ' qr-scanner'
199199
200200@Component ({
201201 components: { QRReader }
@@ -207,6 +207,12 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
207207 cameraScanSource: null | string = null
208208 cameraSelectionMenuOpen = false
209209
210+ hasDeviceCamera = false
211+
212+ async mounted () {
213+ this .hasDeviceCamera = await QrScanner .hasCamera ()
214+ }
215+
210216 @Watch (' open' )
211217 onOpen () {
212218 if (this .open ) {
@@ -217,9 +223,13 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
217223 SocketActions .serverFilesMetadata (this .currentFileName )
218224 }
219225
220- const autoOpenCameraId = this .$store .state .config .uiSettings .spoolman .autoOpenQRDetectionCamera
221- if (this .$store .getters [' cameras/getCameraById' ](autoOpenCameraId )) {
222- this .$nextTick (() => (this .cameraScanSource = autoOpenCameraId ))
226+ if (this .hasDeviceCamera && this .$store .state .config .uiSettings .spoolman .preferDeviceCamera ) {
227+ this .$nextTick (() => (this .cameraScanSource = ' device' ))
228+ } else {
229+ const autoOpenCameraId = this .$store .state .config .uiSettings .spoolman .autoOpenQRDetectionCamera
230+ if (this .$store .getters [' cameras/getCameraById' ](autoOpenCameraId )) {
231+ this .$nextTick (() => (this .cameraScanSource = autoOpenCameraId ))
232+ }
223233 }
224234 }
225235 }
@@ -260,6 +270,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
260270 get headers () {
261271 return [
262272 ' filament_name' ,
273+ ' id' ,
263274 ' material' ,
264275 ' location' ,
265276 ' comment' ,
@@ -302,8 +313,15 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
302313 }
303314
304315 get cameras () {
305- return this .$store .getters [' cameras/getEnabledCameras' ]
316+ const cameras = this .$store .getters [' cameras/getEnabledCameras' ]
306317 .filter ((camera : CameraConfig ) => camera .service !== ' iframe' )
318+
319+ if (this .hasDeviceCamera ) {
320+ // always show device camera first
321+ cameras .unshift ({ name: this .$t (' app.spoolman.label.device_camera' ), id: ' device' })
322+ }
323+
324+ return cameras
307325 }
308326
309327 get scanSource () {
@@ -325,6 +343,10 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
325343 // clear filter if selected spool isn't in filter results
326344 this .search = ' '
327345 }
346+
347+ if (this .$store .state .config .uiSettings .spoolman .autoSelectSpoolOnMatch ) {
348+ this .handleSelectSpool ()
349+ }
328350 }
329351
330352 async handleSelectSpool () {
0 commit comments