-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spoolman): add multi tool support (#1946)
- Loading branch information
Showing
6 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<v-menu :offset-y="true" :close-on-content-click="false" left> | ||
<template #activator="{ on, attrs }"> | ||
<v-btn icon tile v-bind="attrs" v-on="on"> | ||
<v-icon>{{ mdiSwapVertical }}</v-icon> | ||
</v-btn> | ||
</template> | ||
<v-list dense> | ||
<v-list-item> | ||
<v-btn small @click="showChangeSpoolDialog = true"> | ||
<v-icon left>{{ mdiSwapVertical }}</v-icon> | ||
{{ $t('Panels.SpoolmanPanel.ActiveSpool') }} | ||
</v-btn> | ||
</v-list-item> | ||
<spoolman-tools-dropdown-item v-for="tool in tools" :key="tool" :object-name="tool" /> | ||
</v-list> | ||
<spoolman-change-spool-dialog :show-dialog="showChangeSpoolDialog" @close="showChangeSpoolDialog = false" /> | ||
</v-menu> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import { mdiSwapVertical } from '@mdi/js' | ||
import SpoolmanToolsDropdownItem from '@/components/panels/Spoolman/SpoolmanToolsDropdownItem.vue' | ||
@Component({ | ||
components: { SpoolmanToolsDropdownItem }, | ||
}) | ||
export default class SpoolmanToolsDropdown extends Mixins(BaseMixin) { | ||
mdiSwapVertical = mdiSwapVertical | ||
showChangeSpoolDialog = false | ||
@Prop({ required: false, default: false }) readonly tools!: string[] | ||
} | ||
</script> |
66 changes: 66 additions & 0 deletions
66
src/components/panels/Spoolman/SpoolmanToolsDropdownItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<v-list-item> | ||
<v-btn small @click="showChangeSpoolDialog = true"> | ||
<span v-if="color != null" class="_extruderColorState mr-2" :style="dotStyle" /> | ||
{{ name }} | ||
<span v-if="spoolId === null" class="font-italic ml-1">({{ $t('Panels.SpoolmanPanel.NoSpool') }})</span> | ||
<span v-else class="ml-1">({{ spool?.filament?.name ?? '--' }})</span> | ||
</v-btn> | ||
<spoolman-change-spool-dialog | ||
:show-dialog="showChangeSpoolDialog" | ||
:tool="name" | ||
@close="showChangeSpoolDialog = false" /> | ||
</v-list-item> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' | ||
@Component({ | ||
components: {}, | ||
}) | ||
export default class SpoolmanToolsDropdownItem extends Mixins(BaseMixin) { | ||
@Prop({ required: false, default: false }) readonly objectName!: string | ||
showChangeSpoolDialog = false | ||
get name() { | ||
return (this.objectName.split(' ')[1] ?? 'Unknown').toUpperCase() | ||
} | ||
get color() { | ||
return this.spool?.filament?.color_hex ?? '000000' | ||
} | ||
get dotStyle() { | ||
return { | ||
'background-color': '#' + this.color, | ||
} | ||
} | ||
get spoolId() { | ||
const object = this.$store.state.printer[this.objectName] ?? {} | ||
return object.spool_id ?? null | ||
} | ||
get spool() { | ||
return this.spools.find((spool) => spool.id === this.spoolId) ?? null | ||
} | ||
get spools(): ServerSpoolmanStateSpool[] { | ||
return this.$store.state.server.spoolman.spools ?? [] | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
._extruderColorState { | ||
width: 12px; | ||
height: 12px; | ||
border-radius: 50%; | ||
border: 1px solid lightgray; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters