Skip to content

Commit

Permalink
fix: printer farm background image
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Dec 13, 2023
1 parent 6df40c1 commit 1e4e9a3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/components/TheSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { navigationWidth, topbarHeight } from '@/store/variables'
import MainsailLogo from '@/components/ui/MainsailLogo.vue'
import SidebarItem from '@/components/ui/SidebarItem.vue'
import NavigationMixin from '@/components/mixins/navigation'
import ThemeMixin from '@/components/mixins/theme'
@Component({
components: {
Expand All @@ -65,7 +66,7 @@ import NavigationMixin from '@/components/mixins/navigation'
MainsailLogo,
},
})
export default class TheSidebar extends Mixins(NavigationMixin, BaseMixin) {
export default class TheSidebar extends Mixins(NavigationMixin, BaseMixin, ThemeMixin) {
navigationWidth = navigationWidth
topbarHeight = topbarHeight
Expand All @@ -82,8 +83,7 @@ export default class TheSidebar extends Mixins(NavigationMixin, BaseMixin) {
}
get sidebarBackground(): string {
const defaultBg = this.$vuetify.theme.dark ? '/img/sidebar-background.svg' : '/img/sidebar-background-light.svg'
return this.$store.getters['files/getCustomSidebarBackground'] ?? defaultBg
return this.$store.getters['files/getCustomSidebarBackground'] ?? this.sidebarBgImage
}
get currentPage(): string {
Expand Down
4 changes: 4 additions & 0 deletions src/components/mixins/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ export default class ThemeMixin extends Vue {
get progressBarColor() {
return this.$vuetify.theme.dark ? 'white' : 'primary'
}

get sidebarBgImage() {
return this.$vuetify.theme.dark ? '/img/sidebar-background.svg' : '/img/sidebar-background-light.svg'
}
}
27 changes: 15 additions & 12 deletions src/components/panels/FarmPrinterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@
style="background-color: rgba(0, 0, 0, 0.3); backdrop-filter: blur(3px)">
<v-row>
<v-col class="col-auto pr-0 d-flex align-center" style="width: 58px">
<template v-if="printer_logo">
<img :src="printer_logo" style="width: 100%" class="my-auto" alt="Logo" />
</template>
<template v-else>
<mainsail-logo
:color="printerLogoColor"
style="width: 100%"
class="my-auto"></mainsail-logo>
</template>
<img
v-if="printer_logo"
:src="printer_logo"
style="width: 100%"
class="my-auto"
alt="Logo" />
<mainsail-logo
v-else
:color="printerLogoColor"
style="width: 100%"
class="my-auto" />
</v-col>
<v-col class="col" style="width: 100px">
<h3 class="font-weight-regular">{{ printer_status }}</h3>
Expand Down Expand Up @@ -121,6 +123,7 @@ import { Debounce } from 'vue-debounce-decorator'
import WebcamMixin from '@/components/mixins/webcam'
import WebcamWrapper from '@/components/webcams/WebcamWrapper.vue'
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'
import ThemeMixin from '@/components/mixins/theme'
@Component({
components: {
Expand All @@ -129,7 +132,7 @@ import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types'
'mainsail-logo': MainsailLogo,
},
})
export default class FarmPrinterPanel extends Mixins(BaseMixin, WebcamMixin) {
export default class FarmPrinterPanel extends Mixins(BaseMixin, ThemeMixin, WebcamMixin) {
mdiPrinter3d = mdiPrinter3d
mdiWebcam = mdiWebcam
mdiMenuDown = mdiMenuDown
Expand Down Expand Up @@ -176,9 +179,9 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin, WebcamMixin) {
}
get printer_image() {
if (this.currentWebcam) return '/img/sidebar-background.svg'
if (this.currentWebcam) return this.sidebarBgImage
return this.$store.getters['farm/' + this.printer._namespace + '/getImage']
return this.$store.getters['farm/' + this.printer._namespace + '/getImage'] ?? this.sidebarBgImage
}
get printer_logo() {
Expand Down
4 changes: 2 additions & 2 deletions src/store/farm/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const getters: GetterTree<FarmPrinterState, any> = {
getImage: (state) => {
if (state.current_file.filename && state.current_file.thumbnails?.length) {
const indexLastDir = state.current_file.filename.lastIndexOf('/')
const dir = indexLastDir !== -1 ? state.current_file.filename.substr(0, indexLastDir) + '/' : ''
const dir = indexLastDir !== -1 ? state.current_file.filename.substring(0, indexLastDir) + '/' : ''
const thumbnail = state.current_file.thumbnails.find((thumb) => thumb.width >= thumbnailBigMin)

if (thumbnail && 'relative_path' in thumbnail)
Expand All @@ -140,7 +140,7 @@ export const getters: GetterTree<FarmPrinterState, any> = {
)
}

return '/img/sidebar-background.svg'
return null
},

getThemeFileUrl: (state) => (acceptName: string, acceptExtensions: string[]) => {
Expand Down

0 comments on commit 1e4e9a3

Please sign in to comment.