From 103acb63833eb8933e8225dc0f81913c635a95db Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 26 Mar 2023 18:53:35 +0200 Subject: [PATCH 01/11] refactor: move style section to the bottom Signed-off-by: Stefan Dej --- src/components/TheSidebar.vue | 88 +++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index ffbec317d..40c79fcba 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -1,46 +1,3 @@ - - @@ -272,3 +229,46 @@ export default class TheSidebar extends Mixins(BaseMixin) { } } + + From 37a39065ee5bd84aad5fd422420f3659d28e29e1 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 26 Mar 2023 19:20:50 +0200 Subject: [PATCH 02/11] refactor: add getter for mobile logo class Signed-off-by: Stefan Dej --- src/components/TheSidebar.vue | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index 40c79fcba..1de7bd149 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -16,21 +16,14 @@ v-if="isMobile" router to="/" - :class=" - 'sidebar-logo no-text-decoration no-background no-border ' + - (navigationStyle === 'iconsOnly' ? 'pa-0 justify-center' : '') - " + :class="mobileLogoClass" :style="'height: ' + topbarHeight + 'px'" :ripple="false"> {{ $t('App.Printers') }} - +
@@ -212,6 +205,17 @@ export default class TheSidebar extends Mixins(BaseMixin) { return {} } + get mobileLogoClass() { + const output = ['sidebar-logo', 'no-text-decoration', 'no-background', 'no-border'] + + if (this.navigationStyle === 'iconsOnly') { + output.push('pa-0') + output.push('justify-center') + } + + return output + } + showInNavi(route: AppRoute): boolean { if (['shutdown', 'error', 'disconnected'].includes(this.klippy_state) && !route.alwaysShow) return false else if (route.title === 'Webcam' && !this.boolNaviWebcam) return false From 31441cc5364b2e3ca7fe95ceb0c3d6caae4f81e2 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 26 Mar 2023 19:56:20 +0200 Subject: [PATCH 03/11] refactor: add positions in routes and sort output Signed-off-by: Stefan Dej --- src/components/TheSidebar.vue | 18 +++++++++++++++++- src/routes/index.ts | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index 1de7bd149..f1530de4b 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -131,12 +131,28 @@ export default class TheSidebar extends Mixins(BaseMixin) { return this.$store.getters['files/getSidebarBackground'] } - get naviPoints(): AppRoute[] { + get routesNaviPoints(): AppRoute[] { return routes.filter((element) => { return element.showInNavi && this.showInNavi(element) }) } + get naviPoints(): AppRoute[] { + return this.routesNaviPoints.sort((a, b) => { + const aPos = a.position ?? null + const bPos = b.position ?? null + + if (aPos === null && bPos === null) { + if ((a.title ?? '') < (b.title ?? '')) return -1 + if ((a.title ?? '') > (b.title ?? '')) return 1 + + return 0 + } + + return (aPos ?? 99) - (bPos ?? 99) + }) + } + get klippy_state(): string { return this.$store.state.server.klippy_state } diff --git a/src/routes/index.ts b/src/routes/index.ts index bf79ec282..d7dd38b60 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -28,6 +28,7 @@ const routes: AppRoute[] = [ component: Dashboard, alwaysShow: true, showInNavi: true, + position: 1, }, { title: 'Printers', @@ -43,6 +44,7 @@ const routes: AppRoute[] = [ component: Webcam, alwaysShow: true, showInNavi: true, + position: 2, }, { title: 'Console', @@ -52,6 +54,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, klipperIsConnected: true, + position: 3, }, { title: 'Heightmap', @@ -61,6 +64,7 @@ const routes: AppRoute[] = [ alwaysShow: false, showInNavi: true, klipperComponent: 'bed_mesh', + position: 4, }, { title: 'G-Code Files', @@ -70,6 +74,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, registeredDirectory: 'gcodes', + position: 5, }, { title: 'G-Code Viewer', @@ -78,6 +83,7 @@ const routes: AppRoute[] = [ component: () => import('../pages/Viewer.vue'), alwaysShow: true, showInNavi: true, + position: 6, }, { title: 'History', @@ -87,6 +93,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, moonrakerComponent: 'history', + position: 7, }, { title: 'Timelapse', @@ -96,6 +103,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, moonrakerComponent: 'timelapse', + position: 8, }, { title: 'Machine', @@ -104,6 +112,7 @@ const routes: AppRoute[] = [ component: Machine, alwaysShow: true, showInNavi: true, + position: 9, }, { title: null, @@ -130,4 +139,5 @@ export interface AppRoute { klipperComponent?: string klipperIsConnected?: boolean children?: AppRoute[] + position?: number } From 0696e8516beca990e4df8136696f462de496dae8 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 29 Mar 2023 23:14:04 +0200 Subject: [PATCH 04/11] refactor: exclude SidebarItem from TheSidebar Signed-off-by: Stefan Dej --- src/components/TheSidebar.vue | 145 ++++++++++++++---------------- src/components/ui/SidebarItem.vue | 80 +++++++++++++++++ src/routes/index.ts | 18 ++-- src/store/files/getters.ts | 18 +++- 4 files changed, 169 insertions(+), 92 deletions(-) create mode 100644 src/components/ui/SidebarItem.vue diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index f1530de4b..122c90a67 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -29,51 +29,7 @@ {{ printerName }} - -
- - - {{ $t(`Router.${category.title}`) }} - -
+ @@ -90,17 +46,19 @@ + + diff --git a/src/routes/index.ts b/src/routes/index.ts index d7dd38b60..6964df89b 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -28,7 +28,7 @@ const routes: AppRoute[] = [ component: Dashboard, alwaysShow: true, showInNavi: true, - position: 1, + position: 10, }, { title: 'Printers', @@ -44,7 +44,7 @@ const routes: AppRoute[] = [ component: Webcam, alwaysShow: true, showInNavi: true, - position: 2, + position: 20, }, { title: 'Console', @@ -54,7 +54,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, klipperIsConnected: true, - position: 3, + position: 30, }, { title: 'Heightmap', @@ -64,7 +64,7 @@ const routes: AppRoute[] = [ alwaysShow: false, showInNavi: true, klipperComponent: 'bed_mesh', - position: 4, + position: 40, }, { title: 'G-Code Files', @@ -74,7 +74,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, registeredDirectory: 'gcodes', - position: 5, + position: 50, }, { title: 'G-Code Viewer', @@ -83,7 +83,7 @@ const routes: AppRoute[] = [ component: () => import('../pages/Viewer.vue'), alwaysShow: true, showInNavi: true, - position: 6, + position: 60, }, { title: 'History', @@ -93,7 +93,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, moonrakerComponent: 'history', - position: 7, + position: 70, }, { title: 'Timelapse', @@ -103,7 +103,7 @@ const routes: AppRoute[] = [ alwaysShow: true, showInNavi: true, moonrakerComponent: 'timelapse', - position: 8, + position: 80, }, { title: 'Machine', @@ -112,7 +112,7 @@ const routes: AppRoute[] = [ component: Machine, alwaysShow: true, showInNavi: true, - position: 9, + position: 90, }, { title: null, diff --git a/src/store/files/getters.ts b/src/store/files/getters.ts index 71ca66a6e..829d01db1 100644 --- a/src/store/files/getters.ts +++ b/src/store/files/getters.ts @@ -199,11 +199,14 @@ export const getters: GetterTree = { const file = directory?.childrens?.find( (element: FileStateFile) => - element.filename !== undefined && - element.filename.substr(0, element.filename.lastIndexOf('.')) === acceptName && - acceptExtensions.includes(element.filename.substr(element.filename.lastIndexOf('.') + 1)) + element.filename?.slice(0, element.filename?.lastIndexOf('.')) === acceptName && + acceptExtensions.includes(element.filename?.slice(element.filename?.lastIndexOf('.') + 1)) ) - return file ? rootGetters['socket/getUrl'] + '/server/files/config/' + themeDir + '/' + file.filename : null + if (!file) return null + + return `${rootGetters['socket/getUrl']}/server/files/config/${themeDir}/${ + file.filename + }?timestamp=${file.modified.getTime()}` }, getSidebarLogo: (state, getters) => { @@ -234,6 +237,13 @@ export const getters: GetterTree = { return getters['getThemeFileUrl'](acceptName, acceptExtensions) ?? null }, + getCustomNaviPoints: (state, getters) => { + const acceptName = 'navi' + const acceptExtensions = ['json'] + + return getters['getThemeFileUrl'](acceptName, acceptExtensions) ?? null + }, + getCustomFavicons: (state, getters) => { const acceptName16 = 'favicon-32x32' const acceptName32 = 'favicon-32x32' From 339cd4806ab64f657022ef7eab0f826d0351634d Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 30 Mar 2023 21:25:50 +0200 Subject: [PATCH 05/11] feat: add target function for sidebar custom items Signed-off-by: Stefan Dej --- src/components/TheSidebar.vue | 9 +++++---- src/components/ui/SidebarItem.vue | 27 ++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index 122c90a67..b2b4ee2a6 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -93,7 +93,7 @@ export default class TheSidebar extends Mixins(BaseMixin) { points.push({ title: this.$t('App.Printers'), icon: mdiViewDashboardOutline, - path: '/allPrinters', + to: '/allPrinters', position: 0, } as NaviPoint) } @@ -106,7 +106,7 @@ export default class TheSidebar extends Mixins(BaseMixin) { points.push({ title: this.$t(`Router.${element.title}`), icon: element.icon, - path: element.path, + to: element.path, position: element.position ?? 999, } as NaviPoint) }) @@ -217,11 +217,12 @@ export default class TheSidebar extends Mixins(BaseMixin) { throw err }) - content.forEach((item: { title?: string; path?: string; icon?: string; position?: number }) => { + content.forEach((item: NaviPoint) => { this.customNaviLinks.push({ title: item.title ?? 'Unknown', icon: item.icon ?? mdiLinkVariant, - path: item.path ?? '#', + href: item.href ?? '#', + target: item.target ?? undefined, position: item.position ?? 999, } as NaviPoint) }) diff --git a/src/components/ui/SidebarItem.vue b/src/components/ui/SidebarItem.vue index 8f150fba4..c8345d088 100644 --- a/src/components/ui/SidebarItem.vue +++ b/src/components/ui/SidebarItem.vue @@ -2,7 +2,14 @@
- + diff --git a/src/components/mixins/navigation.ts b/src/components/mixins/navigation.ts index 4888c9938..61604715a 100644 --- a/src/components/mixins/navigation.ts +++ b/src/components/mixins/navigation.ts @@ -4,6 +4,7 @@ import { Mixins, Watch } from 'vue-property-decorator' import { mdiLinkVariant, mdiViewDashboardOutline } from '@mdi/js' import BaseMixin from '@/components/mixins/base' import { PrinterStateKlipperConfig } from '@/store/printer/types' +import { GuiNavigationStateEntry } from '@/store/gui/navigation/types' export interface NaviPoint { type: 'link' | 'route' @@ -41,26 +42,40 @@ export default class NavigationMixin extends Mixins(BaseMixin) { return element.showInNavi && this.showInNavi(element) }) .forEach((element) => { + const [position, visible] = this.getUiSettings({ + type: 'route', + title: element.title ?? 'unknown', + visible: true, + position: element.position ?? 999, + }) + points.push({ type: 'route', title: this.$t(`Router.${element.title}`), icon: element.icon, to: element.path, - position: element.position ?? 999, - visible: true, + position, + visible, } as NaviPoint) }) if (this.customNaviLinks.length) { this.customNaviLinks.forEach((element) => { + const [position, visible] = this.getUiSettings({ + type: 'link', + title: element.title ?? 'unknown', + visible: element.visible ?? true, + position: element.position ?? 999, + }) + points.push({ type: 'link', title: element.title, icon: element.icon, href: element.href, target: element.target, - position: element.position, - visible: true, + position, + visible, }) }) } @@ -72,6 +87,14 @@ export default class NavigationMixin extends Mixins(BaseMixin) { return this.routesNaviPoints.sort((a, b) => a.position - b.position) } + get visibleNaviPoints(): NaviPoint[] { + return this.naviPoints.filter((entry) => entry.visible) + } + + get uiSettings(): GuiNavigationStateEntry[] { + return this.$store.state.gui.navigation.entries + } + get klippy_state(): string { return this.$store.state.server.klippy_state } @@ -129,4 +152,14 @@ export default class NavigationMixin extends Mixins(BaseMixin) { return true } + + getUiSettings(entry: GuiNavigationStateEntry): [number, boolean] { + const index = this.uiSettings.findIndex((point) => { + return point.title === entry.title && point.type === entry.type + }) + + if (index === -1) return [entry.position, entry.visible] + + return [this.uiSettings[index].position, this.uiSettings[index].visible] + } } diff --git a/src/components/settings/SettingsNavigationTab.vue b/src/components/settings/SettingsNavigationTab.vue index 9aaa40562..bb4d727cd 100644 --- a/src/components/settings/SettingsNavigationTab.vue +++ b/src/components/settings/SettingsNavigationTab.vue @@ -2,38 +2,12 @@

{{ $t('Settings.NavigationTab.Navigation') }}

- - - - {{ mdiDragVertical }} - - - - - - {{ $t('Settings.MacrosTab.ShowInStatePrinting') }} - - - - + +
@@ -45,30 +19,29 @@ import BaseMixin from '@/components/mixins/base' import NavigationMixin, { NaviPoint } from '@/components/mixins/navigation' import SettingsRow from '@/components/settings/SettingsRow.vue' import draggable from 'vuedraggable' -import { mdiDelete, mdiPrinter3dNozzle, mdiDragVertical, mdiPencil } from '@mdi/js' +import SettingsNavigationTabItem from '@/components/settings/SettingsNavigationTabItem.vue' @Component({ - components: { SettingsRow, draggable }, + components: { SettingsNavigationTabItem, SettingsRow, draggable }, }) export default class SettingsNavigationTab extends Mixins(NavigationMixin, BaseMixin) { - /** - * Icons - */ - mdiPencil = mdiPencil - mdiDelete = mdiDelete - mdiPrinter3dNozzle = mdiPrinter3dNozzle - mdiDragVertical = mdiDragVertical - get sortableNaviPoints() { - return this.naviPoints.filter((naviPoint) => naviPoint.position) + return this.naviPoints.filter((naviPoint) => naviPoint.position > 0) } set sortableNaviPoints(newVal: NaviPoint[]) { - window.console.log('sortableNaviPoints', newVal) - } + // update store with new positions + newVal.forEach((naviPoint, index) => { + this.$store.dispatch('gui/navigation/updatePos', { + type: naviPoint.type, + title: naviPoint.title, + visible: naviPoint.visible, + position: index + 1, + }) + }) - updateOrder() { - console.log('updateOrder') + // upload to moonraker db + this.$store.dispatch('gui/navigation/upload') } } diff --git a/src/components/settings/SettingsNavigationTabItem.vue b/src/components/settings/SettingsNavigationTabItem.vue new file mode 100644 index 000000000..3b9ad9925 --- /dev/null +++ b/src/components/settings/SettingsNavigationTabItem.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 77183051d..a52da656b 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -10,10 +10,11 @@ import { console } from '@/store/gui/console' import { gcodehistory } from '@/store/gui/gcodehistory' import { macros } from '@/store/gui/macros' import { miscellaneous } from '@/store/gui/miscellaneous' +import { navigation } from '@/store/gui/navigation' +import { notifications } from '@/store/gui/notifications' import { presets } from '@/store/gui/presets' import { remoteprinters } from '@/store/gui/remoteprinters' import { webcams } from '@/store/gui/webcams' -import { notifications } from '@/store/gui/notifications' export const getDefaultState = (): GuiState => { return { @@ -141,6 +142,9 @@ export const getDefaultState = (): GuiState => { showGCodePanel: false, cncMode: false, }, + navigation: { + entries: [], + }, uiSettings: { logo: defaultLogoColor, primary: defaultPrimaryColor, @@ -263,6 +267,7 @@ export const gui: Module = { gcodehistory, macros, miscellaneous, + navigation, notifications, presets, remoteprinters, diff --git a/src/store/gui/navigation/actions.ts b/src/store/gui/navigation/actions.ts new file mode 100644 index 000000000..da60b2010 --- /dev/null +++ b/src/store/gui/navigation/actions.ts @@ -0,0 +1,27 @@ +import { ActionTree } from 'vuex' +import { RootState } from '@/store/types' +import Vue from 'vue' +import { GuiNavigationState, GuiNavigationStateEntry } from '@/store/gui/navigation/types' + +export const actions: ActionTree = { + reset({ commit }) { + commit('reset') + }, + + upload({ state }) { + Vue.$socket.emit('server.database.post_item', { + namespace: 'mainsail', + key: 'navigation.entries', + value: state.entries, + }) + }, + + updatePos({ commit }, payload: GuiNavigationStateEntry) { + commit('updatePos', payload) + }, + + changeVisibility({ commit, dispatch }, payload: GuiNavigationStateEntry) { + commit('changeVisibility', payload) + dispatch('upload') + }, +} diff --git a/src/store/gui/navigation/getters.ts b/src/store/gui/navigation/getters.ts new file mode 100644 index 000000000..6ef673319 --- /dev/null +++ b/src/store/gui/navigation/getters.ts @@ -0,0 +1,5 @@ +import { GetterTree } from 'vuex' +import { GuiNavigationState } from './types' + +// eslint-disable-next-line +export const getters: GetterTree = {} diff --git a/src/store/gui/navigation/index.ts b/src/store/gui/navigation/index.ts new file mode 100644 index 000000000..c0ca78578 --- /dev/null +++ b/src/store/gui/navigation/index.ts @@ -0,0 +1,23 @@ +import { Module } from 'vuex' +import { actions } from '@/store/gui/navigation/actions' +import { mutations } from '@/store/gui/navigation/mutations' +import { getters } from '@/store/gui/navigation/getters' +import { GuiNavigationState } from '@/store/gui/navigation/types' + +export const getDefaultState = (): GuiNavigationState => { + return { + entries: [], + } +} + +// initial state +const state = getDefaultState() + +// eslint-disable-next-line +export const navigation: Module = { + namespaced: true, + state, + getters, + actions, + mutations, +} diff --git a/src/store/gui/navigation/mutations.ts b/src/store/gui/navigation/mutations.ts new file mode 100644 index 000000000..57afc98e5 --- /dev/null +++ b/src/store/gui/navigation/mutations.ts @@ -0,0 +1,62 @@ +import { getDefaultState } from './index' +import { MutationTree } from 'vuex' +import { GuiNavigationState, GuiNavigationStateEntry } from './types' +import Vue from 'vue' + +export const mutations: MutationTree = { + reset(state) { + Object.assign(state, getDefaultState()) + }, + + updatePos(state, payload: GuiNavigationStateEntry) { + const index = state.entries.findIndex((entry) => { + return entry.type === payload.type && entry.title === payload.title + }) + + // update existing entry + if (index !== -1) { + state.entries[index].position = payload.position + return + } + + // create new entry + const newEntry: GuiNavigationStateEntry = { + type: payload.type, + title: payload.title, + visible: payload.visible, + position: payload.position, + } + // copy old array + const entries = [...state.entries] + // add new entry + entries.push(newEntry) + // set new array + Vue.set(state, 'entries', entries) + }, + + changeVisibility(state, payload: GuiNavigationStateEntry) { + const index = state.entries.findIndex((entry) => { + return entry.type === payload.type && entry.title === payload.title + }) + + // update existing entry + if (index !== -1) { + state.entries[index].visible = !payload.visible + return + } + + // create new entry + const newEntry: GuiNavigationStateEntry = { + type: payload.type, + title: payload.title, + visible: !payload.visible, + position: payload.position, + } + // copy old array + const entries = [...state.entries] + // add new entry + entries.push(newEntry) + // set new array + Vue.set(state, 'entries', entries) + }, +} diff --git a/src/store/gui/navigation/types.ts b/src/store/gui/navigation/types.ts new file mode 100644 index 000000000..705fb7e01 --- /dev/null +++ b/src/store/gui/navigation/types.ts @@ -0,0 +1,10 @@ +export interface GuiNavigationState { + entries: GuiNavigationStateEntry[] +} + +export interface GuiNavigationStateEntry { + type: 'route' | 'link' + title: string + visible: boolean + position: number +} diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index c598b3daa..aa07153d5 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -5,6 +5,7 @@ import { GuiRemoteprintersState } from '@/store/gui/remoteprinters/types' import { ServerHistoryStateJob } from '@/store/server/history/types' import { GuiNotificationState } from '@/store/gui/notifications/types' import { FileStateFile, FileStateGcodefile } from '@/store/files/types' +import { GuiNavigationState } from '@/store/gui/navigation/types' export interface GuiState { general: { @@ -90,6 +91,7 @@ export interface GuiState { cncMode: boolean } macros?: GuiMacrosState + navigation: GuiNavigationState notifications?: GuiNotificationState presets?: GuiPresetsState remoteprinters?: GuiRemoteprintersState From 83e762dfc2040d4acc4f2fe7b54f8d1e0f2d9a09 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 10 Apr 2023 12:15:50 +0200 Subject: [PATCH 09/11] feat: hide webcam navi point without any webcam config Signed-off-by: Stefan Dej --- src/components/mixins/navigation.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/mixins/navigation.ts b/src/components/mixins/navigation.ts index 61604715a..ea1318890 100644 --- a/src/components/mixins/navigation.ts +++ b/src/components/mixins/navigation.ts @@ -119,6 +119,10 @@ export default class NavigationMixin extends Mixins(BaseMixin) { return this.$store.getters['files/getCustomNaviPoints'] } + get webcamCount(): number { + return this.$store.getters['gui/webcams/getWebcams'].length + } + @Watch('sidebarNaviFile', { immediate: true }) async sidebarNaviFileChanged(newVal: string) { this.customNaviLinks = [] @@ -143,7 +147,7 @@ export default class NavigationMixin extends Mixins(BaseMixin) { showInNavi(route: AppRoute): boolean { if (['shutdown', 'error', 'disconnected'].includes(this.klippy_state) && !route.alwaysShow) return false - else if (route.title === 'Webcam' && !this.boolNaviWebcam) return false + else if (route.title === 'Webcam' && this.webcamCount === 0) return false else if (route.moonrakerComponent && !this.moonrakerComponents.includes(route.moonrakerComponent)) return false else if (route.registeredDirectory && !this.registeredDirectories.includes(route.registeredDirectory)) return false From 4766528eac8c277ba7f80b573934b99889d62ca6 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 10 Apr 2023 12:18:14 +0200 Subject: [PATCH 10/11] refactor: remove boolWebcamInNavi from uiSettings Signed-off-by: Stefan Dej --- src/components/settings/SettingsUiSettingsTab.vue | 12 ------------ src/locales/en.json | 1 - src/store/gui/index.ts | 1 - src/store/gui/types.ts | 1 - 4 files changed, 15 deletions(-) diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 3e6465547..f15ceb4db 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -65,10 +65,6 @@ - - - - { boolBigThumbnail: true, boolWideNavDrawer: false, boolHideUploadAndPrintButton: false, - boolWebcamNavi: false, navigationStyle: 'iconsAndText', powerDeviceName: null, hideSaveConfigForBedMash: false, diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index aa07153d5..bb5f4f328 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -106,7 +106,6 @@ export interface GuiState { boolBigThumbnail: boolean boolWideNavDrawer: boolean boolHideUploadAndPrintButton: boolean - boolWebcamNavi: boolean navigationStyle: 'iconsAndText' | 'iconsOnly' powerDeviceName: string | null hideSaveConfigForBedMash: boolean From 200a17dfb04665b9c9055bb22822b7b9cb76c903 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 1 May 2023 22:59:35 +0200 Subject: [PATCH 11/11] fix: fix errors if no navi.json exists Signed-off-by: Stefan Dej --- src/components/mixins/navigation.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/mixins/navigation.ts b/src/components/mixins/navigation.ts index ea1318890..e286dfef9 100644 --- a/src/components/mixins/navigation.ts +++ b/src/components/mixins/navigation.ts @@ -127,6 +127,9 @@ export default class NavigationMixin extends Mixins(BaseMixin) { async sidebarNaviFileChanged(newVal: string) { this.customNaviLinks = [] + // stop if no file is set + if (!newVal) return + const content = await fetch(newVal) .then((res) => res.json()) .catch((err) => {