feat: each viewport size can have different panels open/close (#696)
This commit is contained in:
1 parent
898878977f
commit
fc7dec8bfa
10 files changed
+55
-21
No files matched your search
@@ -61,6 +61,13 @@ export default class BaseMixin extends Vue {
|
||||
return this.$vuetify.breakpoint.xl
|
||||
}
|
||||
|
||||
get viewport() {
|
||||
if (this.isMobile) return 'mobile'
|
||||
else if (this.isTablet) return 'tablet'
|
||||
else if (this.isDesktop) return 'desktop'
|
||||
else return 'widescreen'
|
||||
}
|
||||
|
||||
get isTouchDevice() {
|
||||
// ignore if browser reports maxTouchPoints === 256, can happen on Windows 10
|
||||
return 'ontouchstart' in window || (navigator.maxTouchPoints > 0 && navigator.maxTouchPoints !== 256)
|
||||
|
||||
@@ -87,7 +87,7 @@ import { mdiMenuDown, mdiViewGrid, mdiWebcam } from '@mdi/js'
|
||||
},
|
||||
})
|
||||
export default class WebcamPanel extends Mixins(BaseMixin) {
|
||||
@Prop({ default: 'dashboard' }) declare viewport?: string
|
||||
@Prop({ default: 'dashboard' }) declare currentPage?: string
|
||||
|
||||
mdiWebcam = mdiWebcam
|
||||
mdiMenuDown = mdiMenuDown
|
||||
@@ -100,7 +100,7 @@ export default class WebcamPanel extends Mixins(BaseMixin) {
|
||||
get currentCamId(): string {
|
||||
if (this.webcams.length === 1) return this.webcams[0].id ?? 'all'
|
||||
|
||||
let currentCamId = this.$store.state.gui.view.webcam.currentCam[this.viewport ?? ''] ?? 'all'
|
||||
let currentCamId = this.$store.state.gui.view.webcam.currentCam[this.currentPage ?? ''] ?? 'all'
|
||||
if (this.webcams.findIndex((webcam: GuiWebcamStateWebcam) => webcam.id === currentCamId) !== -1)
|
||||
return currentCamId
|
||||
else if (currentCamId !== undefined && this.webcams.length === 1) return this.webcams[0].id ?? ''
|
||||
@@ -108,7 +108,7 @@ export default class WebcamPanel extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
set currentCamId(newVal: string) {
|
||||
this.$store.dispatch('gui/setCurrentWebcam', { viewport: this.viewport, value: newVal })
|
||||
this.$store.dispatch('gui/setCurrentWebcam', { page: this.currentPage, value: newVal })
|
||||
}
|
||||
|
||||
get currentCam(): any {
|
||||
|
||||
@@ -92,11 +92,11 @@ export default class Panel extends Mixins(BaseMixin) {
|
||||
@Prop({ default: false }) declare readonly hideButtonsOnCollapse: boolean
|
||||
|
||||
get expand() {
|
||||
return this.$store.getters['gui/getPanelExpand'](this.cardClass)
|
||||
return this.$store.getters['gui/getPanelExpand'](this.cardClass, this.viewport)
|
||||
}
|
||||
|
||||
set expand(newVal) {
|
||||
this.$store.dispatch('gui/saveExpandPanel', { name: this.cardClass, value: newVal })
|
||||
this.$store.dispatch('gui/saveExpandPanel', { name: this.cardClass, value: newVal, viewport: this.viewport })
|
||||
}
|
||||
|
||||
get hasIconSlot() {
|
||||
|
||||
@@ -42,11 +42,15 @@ export default class Panel extends Mixins(BaseMixin) {
|
||||
@Prop({ required: true }) declare readonly subPanelClass: string
|
||||
|
||||
get expand() {
|
||||
return this.$store.getters['gui/getPanelExpand'](this.subPanelClass)
|
||||
return this.$store.getters['gui/getPanelExpand'](this.subPanelClass, this.viewport)
|
||||
}
|
||||
|
||||
set expand(newVal) {
|
||||
this.$store.dispatch('gui/saveExpandPanel', { name: this.subPanelClass, value: newVal })
|
||||
this.$store.dispatch('gui/saveExpandPanel', {
|
||||
name: this.subPanelClass,
|
||||
value: newVal,
|
||||
viewport: this.viewport,
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@
|
||||
<div>
|
||||
<v-row>
|
||||
<v-col col-12>
|
||||
<webcam-panel viewport="page"></webcam-panel>
|
||||
<webcam-panel current-page="page"></webcam-panel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
|
||||
@@ -49,6 +49,20 @@ export const actions: ActionTree<GuiState, RootState> = {
|
||||
delete payload.value.presets
|
||||
}
|
||||
|
||||
//update nonExpandPanels from V2.1.x to V2.2.0
|
||||
if (
|
||||
'dashboard' in payload.value &&
|
||||
'nonExpandPanels' in payload.value.dashboard &&
|
||||
Array.isArray(payload.value.dashboard.nonExpandPanels)
|
||||
) {
|
||||
await fetch(mainsailUrl + '&key=dashboard.nonExpandPanels', { method: 'DELETE' })
|
||||
dispatch('saveSetting', {
|
||||
name: 'dashboard.nonExpandPanels.widescreen',
|
||||
value: payload.value.dashboard.nonExpandPanels,
|
||||
})
|
||||
delete payload.value.dashboard.nonExpandPanels
|
||||
}
|
||||
|
||||
commit('setData', payload.value)
|
||||
},
|
||||
|
||||
@@ -351,12 +365,12 @@ export const actions: ActionTree<GuiState, RootState> = {
|
||||
},
|
||||
|
||||
saveExpandPanel({ commit, dispatch, state }, payload) {
|
||||
if (!payload.value) commit('addClosePanel', { name: payload.name })
|
||||
else commit('removeClosePanel', { name: payload.name })
|
||||
if (!payload.value) commit('addClosePanel', { name: payload.name, viewport: payload.viewport })
|
||||
else commit('removeClosePanel', { name: payload.name, viewport: payload.viewport })
|
||||
|
||||
dispatch('updateSettings', {
|
||||
keyName: 'dashboard.nonExpandPanels',
|
||||
newVal: state.dashboard.nonExpandPanels,
|
||||
keyName: `dashboard.nonExpandPanels.${payload.viewport}`,
|
||||
newVal: state.dashboard.nonExpandPanels[payload.viewport],
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ export const getters: GetterTree<GuiState, any> = {
|
||||
return true
|
||||
},
|
||||
|
||||
getPanelExpand: (state) => (name: string) => {
|
||||
return !state.dashboard.nonExpandPanels?.includes(name) ?? true
|
||||
getPanelExpand: (state) => (name: string, viewport: string) => {
|
||||
if (!(viewport in state.dashboard.nonExpandPanels)) return true
|
||||
|
||||
return !state.dashboard.nonExpandPanels[viewport].includes(name) ?? true
|
||||
},
|
||||
|
||||
getPanels: (state, getters, rootState) => (viewport: string) => {
|
||||
|
||||
@@ -42,7 +42,12 @@ export const getDefaultState = (): GuiState => {
|
||||
},
|
||||
},
|
||||
dashboard: {
|
||||
nonExpandPanels: [],
|
||||
nonExpandPanels: {
|
||||
mobile: [],
|
||||
tablet: [],
|
||||
desktop: [],
|
||||
widescreen: [],
|
||||
},
|
||||
mobileLayout: [
|
||||
{ name: 'webcam', visible: false },
|
||||
{ name: 'zoffset', visible: true },
|
||||
|
||||
@@ -61,7 +61,7 @@ export const mutations: MutationTree<GuiState> = {
|
||||
},
|
||||
|
||||
setCurrentWebcam(state, payload) {
|
||||
Vue.set(state.view.webcam.currentCam, payload.viewport, payload.value)
|
||||
Vue.set(state.view.webcam.currentCam, payload.page, payload.value)
|
||||
},
|
||||
|
||||
setHistoryColumns(state, data) {
|
||||
@@ -77,22 +77,22 @@ export const mutations: MutationTree<GuiState> = {
|
||||
},
|
||||
|
||||
addClosePanel(state, payload) {
|
||||
const nonExpandPanels = [...state.dashboard.nonExpandPanels]
|
||||
const nonExpandPanels = [...state.dashboard.nonExpandPanels[payload.viewport]]
|
||||
|
||||
if (!nonExpandPanels.includes(payload.name)) {
|
||||
nonExpandPanels.push(payload.name)
|
||||
|
||||
Vue.set(state.dashboard, 'nonExpandPanels', nonExpandPanels)
|
||||
Vue.set(state.dashboard.nonExpandPanels, payload.viewport, nonExpandPanels)
|
||||
}
|
||||
},
|
||||
|
||||
removeClosePanel(state, payload) {
|
||||
const nonExpandPanels = [...state.dashboard.nonExpandPanels]
|
||||
const nonExpandPanels = [...state.dashboard.nonExpandPanels[payload.viewport]]
|
||||
const index = nonExpandPanels.indexOf(payload.name)
|
||||
if (index > -1) {
|
||||
nonExpandPanels.splice(index, 1)
|
||||
|
||||
Vue.set(state.dashboard, 'nonExpandPanels', nonExpandPanels)
|
||||
Vue.set(state.dashboard.nonExpandPanels, payload.viewport, nonExpandPanels)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ export interface GuiState {
|
||||
}
|
||||
}
|
||||
dashboard: {
|
||||
nonExpandPanels: string[]
|
||||
nonExpandPanels: {
|
||||
[index: string]: string[]
|
||||
}
|
||||
mobileLayout: GuiStateLayoutoption[]
|
||||
tabletLayout1: GuiStateLayoutoption[]
|
||||
tabletLayout2: GuiStateLayoutoption[]
|
||||
|
||||
Reference in new issue
Block a user