diff --git a/src/components/dialogs/AfcChangeSpoolDialog.vue b/src/components/dialogs/AfcChangeSpoolDialog.vue index dc83faeff..1c9aa5c8a 100644 --- a/src/components/dialogs/AfcChangeSpoolDialog.vue +++ b/src/components/dialogs/AfcChangeSpoolDialog.vue @@ -11,8 +11,10 @@ {{ mdiCloseThick }} + {{ mdiEject }} {{ mdiRefresh }} @@ -44,6 +48,7 @@ + +
+ + + + +
+ + +
+
+ + + +
+ + + + + + + + + + + + +
+
+
+ + + + {{ $t('Panels.AfcSpoolmanPanel.UpdateSpool') }} + + + +
+
@@ -93,6 +147,10 @@ export default class AfcChangeSpoolDialog extends Mixins(BaseMixin) { mdiRefresh = mdiRefresh mdiEject = mdiEject + filamentType = '' + remainingWeight = 0 + spoolColor = '#ffffff' + @Prop({ required: true }) declare readonly showDialog: boolean search = '' @@ -145,6 +203,53 @@ export default class AfcChangeSpoolDialog extends Mixins(BaseMixin) { return this.$store.state.server.config.config?.spoolman?.server ?? null } + updateSpool() { + console.log('Updating spool with the following data:') + console.log('Filament Type:', this.filamentType) + console.log('Remaining Weight:', this.remainingWeight) + console.log('Spool Color:', this.spoolColor) + + if (this.laneData != null) { + const cleanedColor = this.spoolColor.replace('#', '') + + const setColor = `SET_COLOR LANE=${this.laneData.laneName} COLOR=${cleanedColor}` + const setWeight = `SET_WEIGHT LANE=${this.laneData.laneName} WEIGHT=${this.remainingWeight}` + const setMaterial = `SET_MATERIAL LANE=${this.laneData.laneName} MATERIAL=${this.filamentType}` + + this.$nextTick(async () => { + try { + await this.$store.dispatch('printer/sendGcode', setColor) + await this.$store.dispatch('printer/sendGcode', setWeight) + await this.$store.dispatch('printer/sendGcode', setMaterial) + } catch (error) { + console.error('Failed to send G-code:', error) + } + }) + + this.close() + } + } + + manualyClearSpool() { + if (this.laneData != null) { + const cleanedColor = this.spoolColor.replace('#', '') + + const setColor = `SET_COLOR LANE=${this.laneData.laneName} COLOR=000000` + const setWeight = `SET_WEIGHT LANE=${this.laneData.laneName} WEIGHT=0` + const setMaterial = `SET_MATERIAL LANE=${this.laneData.laneName} MATERIAL=` + + this.$nextTick(async () => { + try { + await this.$store.dispatch('printer/sendGcode', setColor) + await this.$store.dispatch('printer/sendGcode', setWeight) + await this.$store.dispatch('printer/sendGcode', setMaterial) + } catch (error) { + console.error('Failed to send G-code:', error) + } + }) + } + } + openSpoolManager() { window.open(this.spoolManagerUrl, '_blank') } @@ -163,20 +268,30 @@ export default class AfcChangeSpoolDialog extends Mixins(BaseMixin) { ejectSpool() { if (this.laneData != null) { - const gcode = `SET_SPOOL_ID LANE=${this.laneData.laneName} SPOOL_ID=` - console.log('Dispatching G-code:', gcode) + const setSpoolId = `SET_SPOOL_ID LANE=${this.laneData.laneName} SPOOL_ID=` + const unloadLane = `LANE_UNLOAD LANE=${this.laneData.laneName}` + console.log('Dispatching G-code:', setSpoolId) + console.log('Dispatching G-code:', unloadLane) this.$nextTick(async () => { try { - await this.$store.dispatch('printer/sendGcode', gcode) - console.log('G-code sent successfully') + await this.$store.dispatch('printer/sendGcode', setSpoolId) + console.log('SET_SPOOL_ID sent successfully') + + await this.$store.dispatch('printer/sendGcode', unloadLane) + console.log('UNLOAD_LANE sent successfully') } catch (error) { console.error('Failed to send G-code:', error) } }) - this.$emit('fetch-spool') - this.close() + // Spoolman not active manualy clear the spool info + if (!this.spoolManagerUrl) { + this.manualyClearSpool() + } + + this.$emit('fetch-spool') + this.close() } } @@ -227,9 +342,47 @@ export default class AfcChangeSpoolDialog extends Mixins(BaseMixin) { this.close() } + initializeFields() { + if (this.laneData) { + console.log('Initializing with laneData:', this.laneData) + this.filamentType = this.laneData.material || '' + this.remainingWeight = this.laneData.weight || 0 + this.spoolColor = this.laneData.color || '#ffffff' + } + } + + resetFields() { + this.filamentType = '' + this.remainingWeight = 0 + this.spoolColor = '#ffffff' + } + @Watch('showDialog') onShowDialogChanged(newVal: boolean) { - if (newVal) this.search = '' + if (newVal) { + if (this.spoolManagerUrl) { + this.search = '' + } + } + } + + @Watch('laneData', { immediate: true }) + onLaneDataChanged() { + if (this.showDialog && this.laneData && !this.spoolManagerUrl) { + this.initializeFields() + } } } + diff --git a/src/components/panels/AfcPanel.vue b/src/components/panels/AfcPanel.vue index 9bb91229c..fa4bb188c 100644 --- a/src/components/panels/AfcPanel.vue +++ b/src/components/panels/AfcPanel.vue @@ -1,169 +1,189 @@ +.theme--light .spool-card, +.theme--light .tool-card { + background-color: #ebebeb; +} + +.filament-reel { + bottom: 5px; + min-width: 30px; + max-width: 40px; + width: 100%; + flex: 1 1 auto; + cursor: pointer; +} + +.infinite-spool { + display: flex; + justify-content: flex-start; + flex-wrap: nowrap; +} +.spacer { + flex-grow: 1; +} + +.afclist { + cursor: pointer; + padding-left: 6px; + padding-right: 1px; + float: left; +} +.theme--dark .spool-card .afclist { + color: white; + background-color: #2e2e2e; +} + +.theme--light .spool-card .afclist { + background-color: #ebebeb; +} + +.infinity-icon { + float: right; + width: 20px; + height: 20px; +} + +.status-light { + width: 10px; + height: 10px; + border-radius: 50%; + display: inline-block; + margin-right: 5px; + margin-left: 5px; +} + +.box-turtle-icon { + width: 70px; + height: 70px; + margin-left: 10px; +} + +.lane-status { + margin-right: 10px; + margin-left: 5px; +} + diff --git a/src/components/ui/FilamentReelIcon.vue b/src/components/ui/FilamentReelIcon.vue index 0496d7035..776617041 100644 --- a/src/components/ui/FilamentReelIcon.vue +++ b/src/components/ui/FilamentReelIcon.vue @@ -1,85 +1,91 @@ - - + diff --git a/src/locales/en.json b/src/locales/en.json index c897531ac..58a29d813 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -608,6 +608,12 @@ "Headline": "Manual Probe" }, "Panels": { + "AfcSpoolmanPanel": { + "FilamentType": "Filament Type", + "RemainingWeight": "Remaining Weight", + "SpoolColor": "Filament Color", + "UpdateSpool": "Update Spool" + }, "ExtruderControlPanel": { "Allowed": "Allowed", "CleanNozzle": "Clean Nozzle",