Skip to content

Commit

Permalink
feat(spoolman): allow selecting more fields
Browse files Browse the repository at this point in the history
Signed-off-by: Mathis Mensing <[email protected]>
  • Loading branch information
matmen committed Jan 19, 2025
1 parent 4470ee9 commit 3e52ba3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/components/settings/SpoolmanSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ export default class SpoolmanSettings extends Mixins(StateMixin) {
'vendor',
'filament_name',
'remaining_weight',
'used_weight',
'location',
'material',
'lot_nr',
'price',
'density',
'extruder_temp',
'bed_temp',
'first_used',
'last_used',
'comment'
Expand Down
23 changes: 20 additions & 3 deletions src/components/widgets/spoolman/SpoolmanCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
</span>
</template>

<template v-else-if="field === 'used_weight'">
<span v-if="remainingFilamentUnit === 'weight'">
{{ $filters.getReadableWeightString(activeSpool.used_weight) }}
<small>/ {{ $filters.getReadableWeightString(activeSpool.filament.weight) }}</small>
</span>
<span v-else-if="remainingFilamentUnit === 'length'">
{{ $filters.getReadableLengthString(activeSpool.used_length) }}
<small>/ {{ $filters.getReadableLengthString($filters.convertFilamentWeightToLength(activeSpool.filament.weight ?? 0, activeSpool.filament.density, activeSpool.filament.diameter)) }}</small>
</span>
</template>

<span v-else>{{ formatField(field) }}</span>
</status-label>
</template>
Expand Down Expand Up @@ -197,9 +208,9 @@ export default class SpoolmanCard extends Mixins(StateMixin) {
get selectedCardFields (): string[] {
const fields = this.$store.state.config.uiSettings.spoolman.selectedCardFields
const NUM_COLUMNS = fields.length > 1 ? 2 : 1
const elementsPerColumn = Math.ceil(fields.length / NUM_COLUMNS)
return new Array(NUM_COLUMNS).fill(undefined).map((_, i) => fields.slice(i * elementsPerColumn, (i + 1) * elementsPerColumn))
const columnCount = fields.length > 1 ? 2 : 1
const elementsPerColumn = Math.ceil(fields.length / columnCount)
return new Array(columnCount).fill(undefined).map((_, i) => fields.slice(i * elementsPerColumn, (i + 1) * elementsPerColumn))
}
get activeSpool (): Spool | null {
Expand Down Expand Up @@ -239,6 +250,7 @@ export default class SpoolmanCard extends Mixins(StateMixin) {
if (!this.activeSpool) return '-'
switch (field) {
case 'id': return this.activeSpool.id
case 'vendor': return this.activeSpool.filament.vendor?.name || '-'
case 'filament_name': return this.activeSpool.filament.name
case 'location': return this.activeSpool.location || '-'
Expand All @@ -247,6 +259,11 @@ export default class SpoolmanCard extends Mixins(StateMixin) {
case 'first_used': return this.activeSpool.first_used ? this.$filters.formatRelativeTimeToNow(this.activeSpool.first_used) : this.$tc('app.setting.label.never')
case 'last_used': return this.activeSpool.last_used ? this.$filters.formatRelativeTimeToNow(this.activeSpool.last_used) : this.$tc('app.setting.label.never')
case 'comment': return this.activeSpool.comment || '-'
case 'price': return this.activeSpool.filament.price || '-'
case 'density': return this.activeSpool.filament.density || '-'
case 'extruder_temp': return this.activeSpool.filament.settings_extruder_temp || '-'
case 'bed_temp': return this.activeSpool.filament.settings_bed_temp || '-'
default:
return field
}
Expand Down
5 changes: 5 additions & 0 deletions src/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -932,16 +932,21 @@ app:
spoolman: Spoolman
label:
active_spool: Aktive Spule
bed_temp: Betttemp.
change_spool: Spule wechseln
comment: Kommentar
density: Dichte
device_camera: Gerät
extruder_temp: Extrudertemp.
filament_name: Filament
first_used: Zuerst genutzt
last_used: Zuletzt genutzt
location: Ort
lot_nr: Charge
material: Material
price: Preis
remaining_weight: Verbleibend
used_weight: Verbraucht
vendor: Hersteller
id: ID
weight: Gewicht
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -891,17 +891,22 @@ app:
scan_spool: Scan Spool
label:
active_spool: Active Spool
bed_temp: Bed Temp
change_spool: Change Spool
comment: Comment
density: Density
device_camera: Device
extruder_temp: Extruder Temp
filament_name: Filament
first_used: First Used
id: ID
last_used: Last Used
location: Location
lot_nr: Lot Nr
material: Material
price: Price
remaining_weight: Remaining
used_weight: Used
vendor: Vendor
weight: Weight
length: Length
Expand Down

0 comments on commit 3e52ba3

Please sign in to comment.