diff --git a/src/components/settings/SpoolmanSettings.vue b/src/components/settings/SpoolmanSettings.vue index 8a244ac842..5881e076c2 100644 --- a/src/components/settings/SpoolmanSettings.vue +++ b/src/components/settings/SpoolmanSettings.vue @@ -54,6 +54,28 @@ /> + + + + + + + + + + (this.cameraScanSource = 'device')) } else { - const autoOpenCameraId = this.$store.state.config.uiSettings.spoolman.autoOpenQRDetectionCamera + const autoOpenCameraId = this.autoOpenQRDetectionCamera if (this.$store.getters['cameras/getCameraById'](autoOpenCameraId)) { this.$nextTick(() => (this.cameraScanSource = autoOpenCameraId)) } @@ -344,7 +344,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi this.search = '' } - if (this.$store.state.config.uiSettings.spoolman.autoSelectSpoolOnMatch) { + if (this.autoSelectSpoolOnMatch) { this.handleSelectSpool() } } @@ -364,30 +364,25 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi } const spool = this.availableSpools.find(spool => spool.id === this.selectedSpool) - if (spool && this.filename) { - // check for enough filament + if (spool && this.filename && (this.warnOnFilamentTypeMismatch || this.warnOnNotEnoughFilament)) { + let requiredLength = 0 // l[mm] - let remainingLength = spool.remaining_length - if (!remainingLength && spool.remaining_weight) { - // l[mm] = m[g]/D[g/cm³]/A[mm²]*(1000mm³/cm³) - remainingLength = spool.remaining_weight / spool.filament.density / (Math.PI * (spool.filament.diameter / 2) ** 2) * 1000 - } - - // l[mm] - let requiredLength = 0 if (this.currentFile) { - const fileMaterial = this.currentFile.filament_type?.toLowerCase() - const spoolMaterial = spool.filament.material?.toLowerCase() - if (spoolMaterial && fileMaterial && fileMaterial !== spoolMaterial) { - // filament materials don't match - - const confirmation = await this.$confirm( - this.$tc('app.spoolman.msg.mismatched_filament'), - { title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$warning' } - ) - - if (!confirmation) { - return + if (this.warnOnFilamentTypeMismatch) { + const fileMaterials = this.currentFile.filament_type?.toLowerCase() + .split(';').map((x: string) => x.replace(/"/g, '')) + const spoolMaterial = spool.filament.material?.toLowerCase() + if (spoolMaterial && fileMaterials && !fileMaterials.includes(spoolMaterial)) { + // filament materials don't match + + const confirmation = await this.$confirm( + this.$tc('app.spoolman.msg.mismatched_filament'), + { title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$warning' } + ) + + if (!confirmation) { + return + } } } @@ -412,16 +407,24 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi } } - if (typeof remainingLength === 'number' && requiredLength >= remainingLength) { - // not enough filament + if (this.warnOnNotEnoughFilament) { + let remainingLength = spool.remaining_length + if (!remainingLength && spool.remaining_weight) { + // l[mm] = m[g]/D[g/cm³]/A[mm²]*(1000mm³/cm³) + remainingLength = spool.remaining_weight / spool.filament.density / (Math.PI * (spool.filament.diameter / 2) ** 2) * 1000 + } - const confirmation = await this.$confirm( - this.$tc('app.spoolman.msg.no_filament'), - { title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$warning' } - ) + if (typeof remainingLength === 'number' && requiredLength >= remainingLength) { + // not enough filament - if (!confirmation) { - return + const confirmation = await this.$confirm( + this.$tc('app.spoolman.msg.no_filament'), + { title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$warning' } + ) + + if (!confirmation) { + return + } } } } @@ -446,6 +449,26 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi get spoolmanURL () { return this.$store.state.server.config.spoolman?.server } + + get preferDeviceCamera () { + return this.$store.state.config.uiSettings.spoolman.preferDeviceCamera + } + + get autoOpenQRDetectionCamera () { + return this.$store.state.config.uiSettings.spoolman.autoOpenQRDetectionCamera + } + + get autoSelectSpoolOnMatch () { + return this.$store.state.config.uiSettings.spoolman.autoSelectSpoolOnMatch + } + + get warnOnNotEnoughFilament () { + return this.$store.state.config.uiSettings.spoolman.warnOnNotEnoughFilament + } + + get warnOnFilamentTypeMismatch (): boolean { + return this.$store.state.config.uiSettings.spoolman.warnOnFilamentTypeMismatch + } } diff --git a/src/locales/de.yaml b/src/locales/de.yaml index 731aa3fb4c..556e854be6 100644 --- a/src/locales/de.yaml +++ b/src/locales/de.yaml @@ -754,3 +754,7 @@ app: auto_select_spool_on_match: Spulenauswahl bei QR-Code- Übereinstimmung automatisch übernehmen prefer_device_camera: Gerätekamera wenn verfügbar zur QR-Code- Erkennung verwenden show_spool_selection_dialog_on_print_start: Spulenauswahl-Dialog automatisch bei Druckstart anzeigen + warn_on_not_enough_filament: >- + Warnung anzeigen, wenn die Spule nicht genug Filament verbleibend hat, um den Druck abzuschließen + warn_on_filament_type_mismatch: >- + Warnung anzeigen, wenn der Filamenttyp der Spule nicht mit dem im Slicer ausgewählten übereinstimmt diff --git a/src/locales/en.yaml b/src/locales/en.yaml index 1d3ff42a3e..1f42ab3d89 100644 --- a/src/locales/en.yaml +++ b/src/locales/en.yaml @@ -821,3 +821,7 @@ app: auto_select_spool_on_match: Automatically commit spool selection on QR code match prefer_device_camera: Use device camera for QR code detection if available show_spool_selection_dialog_on_print_start: Show spool selection dialog on print start + warn_on_not_enough_filament: >- + Show a warning when the selected spool doesn't have enough filament left on it to finish the print + warn_on_filament_type_mismatch: >- + Show a warning when the spool's filament type and the one selected in the slicer don't match diff --git a/src/store/config/state.ts b/src/store/config/state.ts index 38b8e4ee99..2771061ceb 100644 --- a/src/store/config/state.ts +++ b/src/store/config/state.ts @@ -148,7 +148,9 @@ export const defaultState = (): ConfigState => { autoSpoolSelectionDialog: true, autoOpenQRDetectionCamera: null, autoSelectSpoolOnMatch: false, - preferDeviceCamera: false + preferDeviceCamera: false, + warnOnNotEnoughFilament: true, + warnOnFilamentTypeMismatch: true } } } diff --git a/src/store/config/types.ts b/src/store/config/types.ts index 7435b3433a..3e3461c7d3 100644 --- a/src/store/config/types.ts +++ b/src/store/config/types.ts @@ -36,6 +36,8 @@ export interface SpoolmanConfig { autoOpenQRDetectionCamera: string | null; autoSelectSpoolOnMatch: boolean; preferDeviceCamera: boolean; + warnOnNotEnoughFilament: boolean; + warnOnFilamentTypeMismatch: boolean; } export interface HostConfig {