diff --git a/src/App.vue b/src/App.vue index 5b424894..56e9a44f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -114,11 +114,11 @@ export default class App extends Mixins(BaseMixin) { } get logoColor(): string { - return this.$store.state.gui.theme.logo + return this.$store.state.gui.uiSettings.logo } get primaryColor(): string { - return this.$store.state.gui.theme.primary + return this.$store.state.gui.uiSettings.primary } get warningColor(): string { diff --git a/src/components/TheSidebar.vue b/src/components/TheSidebar.vue index f19592c5..fbd7f075 100644 --- a/src/components/TheSidebar.vue +++ b/src/components/TheSidebar.vue @@ -103,7 +103,7 @@ export default class TheSidebarAlt extends Mixins(BaseMixin) { } get navigationStyle() { - return this.$store.state.gui.dashboard.navigationStyle + return this.$store.state.gui.uiSettings.navigationStyle } get sidebarBackground(): string { @@ -119,7 +119,7 @@ export default class TheSidebarAlt extends Mixins(BaseMixin) { } get boolNaviWebcam(): boolean { - return this.$store.state.gui.webcamSettings.boolNavi + return this.$store.state.gui.uiSettings.boolWebcamNavi } get moonrakerComponents(): string[] { diff --git a/src/components/TheTopCornerMenu.vue b/src/components/TheTopCornerMenu.vue index be6b7211..040bb9b8 100644 --- a/src/components/TheTopCornerMenu.vue +++ b/src/components/TheTopCornerMenu.vue @@ -167,7 +167,7 @@ export default class TheTopCornerMenu extends Mixins(BaseMixin) { this.dialogPowerDeviceChange.device = device.device this.dialogPowerDeviceChange.value = value - const confirmOnPowerDeviceChange = this.$store.state.gui.general.confirmOnPowerDeviceChange + const confirmOnPowerDeviceChange = this.$store.state.gui.uiSettings.confirmOnPowerDeviceChange if (confirmOnPowerDeviceChange) { this.dialogPowerDeviceChange.show = true } diff --git a/src/components/TheTopbar.vue b/src/components/TheTopbar.vue index 96d25b92..e49d1820 100644 --- a/src/components/TheTopbar.vue +++ b/src/components/TheTopbar.vue @@ -198,7 +198,7 @@ export default class TheTopbar extends Mixins(BaseMixin) { } get boolWideNavDrawer() { - return this.$store.state.gui.dashboard.boolWideNavDrawer ?? false + return this.$store.state.gui.uiSettings.boolWideNavDrawer ?? false } get countPrinters() { @@ -214,11 +214,11 @@ export default class TheTopbar extends Mixins(BaseMixin) { } get logoColor(): string { - return this.$store.state.gui.theme.logo + return this.$store.state.gui.uiSettings.logo } btnEmergencyStop() { - const confirmOnEmergencyStop = this.$store.state.gui.general.confirmOnEmergencyStop + const confirmOnEmergencyStop = this.$store.state.gui.uiSettings.confirmOnEmergencyStop if (confirmOnEmergencyStop) { this.showEmergencyStopDialog = true } diff --git a/src/components/charts/TempChart.vue b/src/components/charts/TempChart.vue index beae0480..9464a3c3 100644 --- a/src/components/charts/TempChart.vue +++ b/src/components/charts/TempChart.vue @@ -210,7 +210,7 @@ export default class TempChart extends Mixins(BaseMixin) { } get autoscale() { - return this.$store.state.gui.tempchart.autoscale ?? true + return this.$store.state.gui.view.tempchart.autoscale ?? true } get maxTemp() { diff --git a/src/components/inputs/MacroButton.vue b/src/components/inputs/MacroButton.vue index 770aa63f..d8b4e1a8 100644 --- a/src/components/inputs/MacroButton.vue +++ b/src/components/inputs/MacroButton.vue @@ -68,7 +68,7 @@ import Component from 'vue-class-component' import {Mixins, Prop, Watch} from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' -import {GuiMacrogroupsStateMacrogroupMacro} from '@/store/gui/macrogroups/types' +import {GuiMacrosStateMacrogroupMacro} from '@/store/gui/macros/types' interface param { type: 'int' | 'double' | 'string' | null, @@ -85,7 +85,7 @@ export default class MacroButton extends Mixins(BaseMixin) { private paramArray: string[] = [] private params: params = {} - @Prop({ required: true }) readonly macro!: GuiMacrogroupsStateMacrogroupMacro + @Prop({ required: true }) readonly macro!: GuiMacrosStateMacrogroupMacro @Prop({ default: 'primary' }) readonly color!: string get klipperMacro() { diff --git a/src/components/inputs/MiscellaneousSlider.vue b/src/components/inputs/MiscellaneousSlider.vue index 94de529e..7730b2ea 100644 --- a/src/components/inputs/MiscellaneousSlider.vue +++ b/src/components/inputs/MiscellaneousSlider.vue @@ -106,11 +106,11 @@ export default class MiscellaneousSlider extends Mixins(BaseMixin) { } get lockSliders() { - return this.$store.state.gui.general.lockSlidersOnTouchDevices + return this.$store.state.gui.uiSettings.lockSlidersOnTouchDevices } get lockSlidersDelay() { - return this.$store.state.gui.general.lockSlidersDelay + return this.$store.state.gui.uiSettings.lockSlidersDelay } @Debounce(500) diff --git a/src/components/inputs/ToolSlider.vue b/src/components/inputs/ToolSlider.vue index 3e247cbe..7ab98c55 100644 --- a/src/components/inputs/ToolSlider.vue +++ b/src/components/inputs/ToolSlider.vue @@ -119,11 +119,11 @@ export default class ToolSlider extends Mixins(BaseMixin) { } get lockSliders() { - return this.$store.state.gui.general.lockSlidersOnTouchDevices + return this.$store.state.gui.uiSettings.lockSlidersOnTouchDevices } get lockSlidersDelay() { - return this.$store.state.gui.general.lockSlidersDelay + return this.$store.state.gui.uiSettings.lockSlidersDelay } get colorBar() { diff --git a/src/components/mixins/control.ts b/src/components/mixins/control.ts index ec73550e..743c0bbc 100644 --- a/src/components/mixins/control.ts +++ b/src/components/mixins/control.ts @@ -13,11 +13,11 @@ export default class ControlMixin extends Vue { } get feedrateXY() { - return this.$store.state.gui.dashboard?.control?.feedrateXY ?? 100 + return this.$store.state.gui.control?.feedrateXY ?? 100 } get feedrateZ() { - return this.$store.state.gui.dashboard?.control?.feedrateZ ?? 10 + return this.$store.state.gui.control?.feedrateZ ?? 10 } get existsQGL() { diff --git a/src/components/mixins/dashboard.ts b/src/components/mixins/dashboard.ts index 0f780442..e5468bfa 100644 --- a/src/components/mixins/dashboard.ts +++ b/src/components/mixins/dashboard.ts @@ -2,17 +2,17 @@ import Component from 'vue-class-component' import BaseMixin from '@/components/mixins/base' import {allDashboardPanels} from '@/store/variables' import {capitalize} from '@/plugins/helpers' -import {GuiMacrogroupsStateMacrogroup} from '@/store/gui/macrogroups/types' +import {GuiMacrosStateMacrogroup} from '@/store/gui/macros/types' @Component export default class DashboardMixin extends BaseMixin { get macroMode() { - return this.$store.state.gui.dashboard.macroManagement ?? 'simple' + return this.$store.state.gui.macros.mode ?? 'simple' } get macrogroups() { - return this.$store.getters['gui/macrogroups/getAllMacrogroups'] ?? [] + return this.$store.getters['gui/macros/getAllMacrogroups'] ?? [] } get missingPanelsMobile() { @@ -56,7 +56,7 @@ export default class DashboardMixin extends BaseMixin { const missingPanels: any[] = [] if (this.macroMode === 'expert') { - this.macrogroups.forEach((group: GuiMacrogroupsStateMacrogroup) => { + this.macrogroups.forEach((group: GuiMacrosStateMacrogroup) => { allPanels.push('macrogroup_'+group.id) }) @@ -67,7 +67,7 @@ export default class DashboardMixin extends BaseMixin { if (!panels.find((panel) => panel.name === panelname)) missingPanels.push({ name: panelname, - visable: true + visible: true }) }) @@ -77,7 +77,7 @@ export default class DashboardMixin extends BaseMixin { getPanelName(name: string) { if (name.startsWith('macrogroup_')) { const groupId = name.split('_')[1] ?? '' - const group = this.macrogroups.find((group: GuiMacrogroupsStateMacrogroup) => group.id === groupId) + const group = this.macrogroups.find((group: GuiMacrosStateMacrogroup) => group.id === groupId) return (group) ? group.name : 'Macrogroup' } diff --git a/src/components/panels/ControlPanel.vue b/src/components/panels/ControlPanel.vue index 49395529..ec894243 100644 --- a/src/components/panels/ControlPanel.vue +++ b/src/components/panels/ControlPanel.vue @@ -52,7 +52,7 @@ import Panel from '@/components/ui/Panel.vue' }) export default class ControlPanel extends Mixins(BaseMixin) { get controlStyle() { - return this.$store.state.gui.dashboard.control.style ?? 'bars' + return this.$store.state.gui.control.style ?? 'bars' } get existsExtruder() { diff --git a/src/components/panels/ControlPanelBarsControl.vue b/src/components/panels/ControlPanelBarsControl.vue index cb366937..3051ddd2 100644 --- a/src/components/panels/ControlPanelBarsControl.vue +++ b/src/components/panels/ControlPanelBarsControl.vue @@ -55,19 +55,19 @@ import ControlMixin from '@/components/mixins/control' @Component export default class ControlPanelBarsControl extends Mixins(BaseMixin, ControlMixin) { get stepsXYsorted() { - return [...this.$store.state.gui.dashboard.control.stepsXY].sort(function(a, b) { return b-a }) + return [...this.$store.state.gui.control.stepsXY].sort(function(a, b) { return b-a }) } get stepsXYsortedReverse() { - return [...this.$store.state.gui.dashboard.control.stepsXY].sort(function(a, b) { return a-b }) + return [...this.$store.state.gui.control.stepsXY].sort(function(a, b) { return a-b }) } get stepsZsorted() { - return [...this.$store.state.gui.dashboard.control.stepsZ].sort(function(a, b) { return b-a }) + return [...this.$store.state.gui.control.stepsZ].sort(function(a, b) { return b-a }) } get stepsZsortedReverse() { - return [...this.$store.state.gui.dashboard.control.stepsZ].sort(function(a, b) { return a-b }) + return [...this.$store.state.gui.control.stepsZ].sort(function(a, b) { return a-b }) } } diff --git a/src/components/panels/ControlPanelCircleControl.vue b/src/components/panels/ControlPanelCircleControl.vue index 262a2f7c..5ce62843 100644 --- a/src/components/panels/ControlPanelCircleControl.vue +++ b/src/components/panels/ControlPanelCircleControl.vue @@ -344,19 +344,19 @@ import ControlMixin from '@/components/mixins/control' @Component export default class ControlPanelCrossControl extends Mixins(BaseMixin, ControlMixin) { get reverseX() { - return this.$store.state.gui.dashboard.control.reverseX + return this.$store.state.gui.control.reverseX } get reverseY() { - return this.$store.state.gui.dashboard.control.reverseY + return this.$store.state.gui.control.reverseY } get reverseZ() { - return this.$store.state.gui.dashboard.control.reverseZ + return this.$store.state.gui.control.reverseZ } get stepsXY() { - const steps = this.$store.state.gui.dashboard?.control?.stepsCircleXY ?? [] + const steps = this.$store.state.gui.control?.stepsCircleXY ?? [] return Array.from(new Set([ ...(steps ?? []), @@ -364,7 +364,7 @@ export default class ControlPanelCrossControl extends Mixins(BaseMixin, ControlM } get stepsZ() { - const steps = this.$store.state.gui.dashboard?.control?.stepsCircleZ ?? [] + const steps = this.$store.state.gui.control?.stepsCircleZ ?? [] return Array.from(new Set([ ...(steps ?? []), diff --git a/src/components/panels/ControlPanelCrossControl.vue b/src/components/panels/ControlPanelCrossControl.vue index f5d61fe3..1192b8ed 100644 --- a/src/components/panels/ControlPanelCrossControl.vue +++ b/src/components/panels/ControlPanelCrossControl.vue @@ -177,27 +177,27 @@ export default class ControlPanelCrossControl extends Mixins(BaseMixin, ControlM private homeCols = 6 get selectedCrossStep() { - return this.$store.state.gui.dashboard.control.selectedCrossStep + return this.$store.state.gui.control.selectedCrossStep } set selectedCrossStep(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.selectedCrossStep', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.selectedCrossStep', value: newVal }) } get reverseX() { - return this.$store.state.gui.dashboard.control.reverseX + return this.$store.state.gui.control.reverseX } get reverseY() { - return this.$store.state.gui.dashboard.control.reverseY + return this.$store.state.gui.control.reverseY } get reverseZ() { - return this.$store.state.gui.dashboard.control.reverseZ + return this.$store.state.gui.control.reverseZ } get stepsAll() { - return this.$store.state.gui.dashboard?.control?.stepsAll ?? [] + return this.$store.state.gui.control?.stepsAll ?? [] } get stepsReversed() { diff --git a/src/components/panels/ControlPanelExtruder.vue b/src/components/panels/ControlPanelExtruder.vue index f8e81737..2e861b1b 100644 --- a/src/components/panels/ControlPanelExtruder.vue +++ b/src/components/panels/ControlPanelExtruder.vue @@ -85,11 +85,11 @@ export default class ControlPanelExtruder extends Mixins(BaseMixin) { } get feedamounts() { - return this.$store.state.gui.dashboard?.extruder?.feedamounts ?? [] + return this.$store.state.gui.control.extruder?.feedamounts ?? [] } get feedrates() { - return this.$store.state.gui.dashboard?.extruder?.feedrates ?? [] + return this.$store.state.gui.control.extruder?.feedrates ?? [] } get feedamountsSorted() { @@ -101,19 +101,19 @@ export default class ControlPanelExtruder extends Mixins(BaseMixin) { } get currentFeedAmount() { - return parseFloat(this.$store.state.gui.dashboard.extruder.feedamount) + return parseFloat(this.$store.state.gui.control.extruder.feedamount) } set currentFeedAmount(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.extruder.feedamount', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.extruder.feedamount', value: newVal }) } get currentFeedRate() { - return parseFloat(this.$store.state.gui.dashboard.extruder.feedrate) + return parseFloat(this.$store.state.gui.control.extruder.feedrate) } set currentFeedRate(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.extruder.feedrate', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.extruder.feedrate', value: newVal }) } get boolExtrudePossible() { diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index 62a913e4..f0e6fd4a 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -628,55 +628,55 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) { } get hideMetadataColums() { - return this.$store.state.gui.gcodefiles.hideMetadataColums + return this.$store.state.gui.view.gcodefiles.hideMetadataColums } set hideMetadataColums(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.hideMetadataColums', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.hideMetadataColums', value: newVal }) } get showHiddenFiles() { - return this.$store.state.gui.gcodefiles.showHiddenFiles + return this.$store.state.gui.view.gcodefiles.showHiddenFiles } set showHiddenFiles(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.showHiddenFiles', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.showHiddenFiles', value: newVal }) } get showPrintedFiles() { - return this.$store.state.gui.gcodefiles.showPrintedFiles + return this.$store.state.gui.view.gcodefiles.showPrintedFiles } set showPrintedFiles(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.showPrintedFiles', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.showPrintedFiles', value: newVal }) } get sortBy() { - return this.$store.state.gui.gcodefiles.sortBy + return this.$store.state.gui.view.gcodefiles.sortBy } set sortBy(newVal) { if (newVal === undefined) newVal = 'modified' - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.sortBy', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.sortBy', value: newVal }) } get sortDesc() { - return this.$store.state.gui.gcodefiles.sortDesc + return this.$store.state.gui.view.gcodefiles.sortDesc } set sortDesc(newVal) { if (newVal === undefined) newVal = false - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.sortDesc', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.sortDesc', value: newVal }) } get countPerPage() { - return this.$store.state.gui.gcodefiles.countPerPage + return this.$store.state.gui.view.gcodefiles.countPerPage } set countPerPage(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'gcodefiles.countPerPage', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.countPerPage', value: newVal }) } get timelapseEnabled() { diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index c9f0fe65..a7d98d7c 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -473,19 +473,19 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { } get countPerPage() { - return this.$store.state.gui.history.countPerPage + return this.$store.state.gui.view.historycountPerPage } set countPerPage(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'history.countPerPage', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.history.countPerPage', value: newVal }) } get hideColums() { - return this.$store.state.gui.history.hideColums + return this.$store.state.gui.view.history.hideColums } set hideColums(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'history.hideColums', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.history.hideColums', value: newVal }) } refreshHistory() { diff --git a/src/components/panels/HistoryStatisticsPanel.vue b/src/components/panels/HistoryStatisticsPanel.vue index 915b05cb..591f4dbb 100644 --- a/src/components/panels/HistoryStatisticsPanel.vue +++ b/src/components/panels/HistoryStatisticsPanel.vue @@ -89,11 +89,11 @@ export default class HistoryStatisticsPanel extends Mixins(BaseMixin) { } get toggleChart () { - return this.$store.state.gui.history.toggleChartCol3 + return this.$store.state.gui.view.history.toggleChartCol3 } set toggleChart(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'history.toggleChartCol3', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.history.toggleChartCol3', value: newVal }) } formatPrintTime(totalSeconds: number) { diff --git a/src/components/panels/JobqueuePanel.vue b/src/components/panels/JobqueuePanel.vue index a1a7cedf..bc0b5adb 100644 --- a/src/components/panels/JobqueuePanel.vue +++ b/src/components/panels/JobqueuePanel.vue @@ -137,11 +137,11 @@ export default class JobqueuePanel extends Mixins(BaseMixin) { } get countPerPage() { - return this.$store.state.gui.jobqueue.countPerPage + return this.$store.state.gui.view.jobqueue.countPerPage } set countPerPage(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'jobqueue.countPerPage', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.jobqueue.countPerPage', value: newVal }) } refreshHistory() { diff --git a/src/components/panels/Machine/ConfigFilesPanel.vue b/src/components/panels/Machine/ConfigFilesPanel.vue index 1c83c563..279b91fc 100644 --- a/src/components/panels/Machine/ConfigFilesPanel.vue +++ b/src/components/panels/Machine/ConfigFilesPanel.vue @@ -532,47 +532,47 @@ export default class ConfigFilesPanel extends Mixins(BaseMixin) { } get countPerPage() { - return this.$store.state.gui.settings.configfiles.countPerPage + return this.$store.state.gui.view.configfiles.countPerPage } set countPerPage(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'settings.configfiles.countPerPage', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.configfiles.countPerPage', value: newVal }) } get showHiddenFiles() { - return this.$store.state.gui.settings.configfiles.showHiddenFiles + return this.$store.state.gui.view.configfiles.showHiddenFiles } set showHiddenFiles(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'settings.configfiles.showHiddenFiles', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.configfiles.showHiddenFiles', value: newVal }) } get hideBackupFiles() { - return this.$store.state.gui.settings.configfiles.hideBackupFiles + return this.$store.state.gui.view.configfiles.hideBackupFiles } set hideBackupFiles(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'settings.configfiles.hideBackupFiles', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.configfiles.hideBackupFiles', value: newVal }) } get sortBy() { - return this.$store.state.gui.settings.configfiles.sortBy + return this.$store.state.gui.view.configfiles.sortBy } set sortBy(newVal) { if (newVal === undefined) newVal = 'filename' - this.$store.dispatch('gui/saveSetting', { name: 'settings.configfiles.sortBy', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.configfiles.sortBy', value: newVal }) } get sortDesc() { - return this.$store.state.gui.settings.configfiles.sortDesc + return this.$store.state.gui.view.configfiles.sortDesc } set sortDesc(newVal) { if (newVal === undefined) newVal = false - this.$store.dispatch('gui/saveSetting', { name: 'settings.configfiles.sortDesc', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.configfiles.sortDesc', value: newVal }) } get registeredDirectories() { diff --git a/src/components/panels/MacrogroupPanel.vue b/src/components/panels/MacrogroupPanel.vue index c47b37e4..83762519 100644 --- a/src/components/panels/MacrogroupPanel.vue +++ b/src/components/panels/MacrogroupPanel.vue @@ -31,7 +31,7 @@ import BaseMixin from '../mixins/base' import Panel from '@/components/ui/Panel.vue' import MacroButton from '@/components/inputs/MacroButton.vue' import {PrinterStateMacro} from '@/store/printer/types' -import {GuiMacrogroupsStateMacrogroupMacro} from '@/store/gui/macrogroups/types' +import {GuiMacrosStateMacrogroupMacro} from '@/store/gui/macros/types' @Component({ components: {MacroButton, Panel} }) @@ -40,17 +40,17 @@ export default class MacrogroupPanel extends Mixins(BaseMixin) { @Prop({ required: true }) panelId!: string get macrogroup() { - return this.$store.getters['gui/macrogroups/getMacrogroup'](this.panelId) + return this.$store.getters['gui/macros/getMacrogroup'](this.panelId) } get allMacros() { - return this.$store.getters['printer/getMacros'] ?? [] + return this.$store.getters['printer/getAllMacros'] ?? [] } get macros() { let macros = this.macrogroup?.macros ?? [] - macros = macros.filter((macro: GuiMacrogroupsStateMacrogroupMacro) => { + macros = macros.filter((macro: GuiMacrosStateMacrogroupMacro) => { if (!this.allMacros.find((existMacro: PrinterStateMacro) => existMacro.name.toLowerCase() === macro.name.toLowerCase())) return false return ( @@ -60,7 +60,7 @@ export default class MacrogroupPanel extends Mixins(BaseMixin) { ) }) - return macros.sort((a: GuiMacrogroupsStateMacrogroupMacro, b: GuiMacrogroupsStateMacrogroupMacro) => a.pos - b.pos) + return macros.sort((a: GuiMacrosStateMacrogroupMacro, b: GuiMacrosStateMacrogroupMacro) => a.pos - b.pos) } get macrogroupStatus() { @@ -71,7 +71,7 @@ export default class MacrogroupPanel extends Mixins(BaseMixin) { ) } - getColor(macro: GuiMacrogroupsStateMacrogroupMacro) { + getColor(macro: GuiMacrosStateMacrogroupMacro) { if (macro.color === 'group') { if (this.macrogroup.color === 'custom') return this.macrogroup.colorCustom else return this.macrogroup.color diff --git a/src/components/panels/MiniconsolePanel.vue b/src/components/panels/MiniconsolePanel.vue index 182d807f..5c502850 100644 --- a/src/components/panels/MiniconsolePanel.vue +++ b/src/components/panels/MiniconsolePanel.vue @@ -162,7 +162,7 @@ export default class MiniconsolePanel extends Mixins(BaseMixin) { } get lastCommands(): string[] { - return this.$store.state.gui.gcodehistory.history ?? [] + return this.$store.state.gui.gcodehistory.entries ?? [] } commandClick(msg: string): void { diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 0d0fc71f..689e92bb 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -388,7 +388,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { color: 'error', icon: 'mdi-stop', loadingName: 'statusPrintCancel', - status: this.$store.state.gui.general.displayCancelPrint ? ['paused', 'printing'] : ['paused'], + status: this.$store.state.gui.uiSettings.displayCancelPrint ? ['paused', 'printing'] : ['paused'], click: this.btnCancelJob }, { text: this.$t('Panels.StatusPanel.ClearPrintStats'), @@ -573,7 +573,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { } get boolBigThumbnail() { - const setting = this.$store.state.gui.dashboard.boolBigThumbnail ?? true + const setting = this.$store.state.gui.uiSettings.boolBigThumbnail ?? true return this.current_filename && setting && this.thumbnailBig } diff --git a/src/components/panels/Timelapse/TimelapseFilesPanel.vue b/src/components/panels/Timelapse/TimelapseFilesPanel.vue index 61a0bc9f..208623cd 100644 --- a/src/components/panels/Timelapse/TimelapseFilesPanel.vue +++ b/src/components/panels/Timelapse/TimelapseFilesPanel.vue @@ -370,31 +370,31 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) { } get sortBy() { - return this.$store.state.gui.timelapse.sortBy ?? 'modified' + return this.$store.state.gui.view.gcodefiles.sortBy ?? 'modified' } set sortBy(newVal) { if (newVal === undefined) newVal = 'modified' - this.$store.dispatch('gui/saveSetting', { name: 'timelapse.sortBy', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.timelapse.sortBy', value: newVal }) } get sortDesc() { - return this.$store.state.gui.timelapse.sortDesc ?? true + return this.$store.state.gui.view.gcodefiles.sortDesc ?? true } set sortDesc(newVal) { if (newVal === undefined) newVal = false - this.$store.dispatch('gui/saveSetting', { name: 'timelapse.sortDesc', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.timelapse.sortDesc', value: newVal }) } get countPerPage() { - return this.$store.state.gui.timelapse?.countPerPage ?? 10 + return this.$store.state.gui.view.gcodefiles?.countPerPage ?? 10 } set countPerPage(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'timelapse.countPerPage', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.timelapse.countPerPage', value: newVal }) } get displayFiles() { diff --git a/src/components/panels/ToolsPanel.vue b/src/components/panels/ToolsPanel.vue index 90576cf6..ffd01622 100644 --- a/src/components/panels/ToolsPanel.vue +++ b/src/components/panels/ToolsPanel.vue @@ -303,19 +303,19 @@ export default class ToolsPanel extends Mixins(BaseMixin) { } get boolTempchart(): boolean { - return this.$store.state.gui.dashboard?.boolTempchart ?? false + return this.$store.state.gui.view.tempchart.boolTempchart ?? false } set boolTempchart(newVal: boolean) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.boolTempchart', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.tempchart.boolTempchart', value: newVal }) } get autoscaleTempchart(): boolean { - return this.$store.state.gui.tempchart.autoscale ?? false + return this.$store.state.gui.view.tempchart.autoscale ?? false } set autoscaleTempchart(newVal: boolean) { - this.$store.dispatch('gui/saveSetting', { name: 'tempchart.autoscale', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'view.tempchart.autoscale', value: newVal }) } get heaters(): PrinterStateHeater[] { @@ -377,12 +377,12 @@ export default class ToolsPanel extends Mixins(BaseMixin) { const serieName = 'bool'+type.charAt(0).toUpperCase() + type.slice(1) const value = this.editHeater[serieName] - const name = 'tempchart.datasetSettings.'+this.editHeater.name+'.'+type + const name = 'view.tempchart.datasetSettings.'+this.editHeater.name+'.'+type this.$store.dispatch('gui/saveSetting', { name, value }) } setVisibleAdditionalSensor(sensor: string): void { - const name = 'tempchart.datasetSettings.'+this.editHeater.name+'.additionalSensors.'+sensor + const name = 'view.tempchart.datasetSettings.'+this.editHeater.name+'.additionalSensors.'+sensor this.$store.dispatch('gui/saveSetting', { name, value: this.editHeater.additionSensors[sensor].bool }) } @@ -391,7 +391,7 @@ export default class ToolsPanel extends Mixins(BaseMixin) { if (typeof value === 'object' && 'hex' in value) value = value.hex this.$store.commit('printer/tempHistory/setColor', { name: this.editHeater.name, value: value }) - const name = 'tempchart.datasetSettings.'+this.editHeater.name+'.color' + const name = 'view.tempchart.datasetSettings.'+this.editHeater.name+'.color' this.$store.dispatch('gui/saveSetting', { name, value }) } diff --git a/src/components/panels/ZoffsetPanel.vue b/src/components/panels/ZoffsetPanel.vue index 96947b46..b21789a7 100644 --- a/src/components/panels/ZoffsetPanel.vue +++ b/src/components/panels/ZoffsetPanel.vue @@ -104,7 +104,7 @@ export default class ZoffsetPanel extends Mixins(BaseMixin) { } get displayZOffsetStandby() { - return this.$store.state.gui.general.displayZOffsetStandby ?? false + return this.$store.state.gui.uiSettings.displayZOffsetStandby ?? false } get homing_origin() { diff --git a/src/components/settings/SettingsConsoleTab.vue b/src/components/settings/SettingsConsoleTab.vue index ae4d04ca..1a138b28 100644 --- a/src/components/settings/SettingsConsoleTab.vue +++ b/src/components/settings/SettingsConsoleTab.vue @@ -120,7 +120,7 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } get consoleFilters() { - return this.$store.getters['gui/consolefilters/getConsolefilters'] ?? [] + return this.$store.getters['gui/console/getConsolefilters'] ?? [] } get availableDirections() { @@ -140,7 +140,7 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } set consoleDirection(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'console.direction', value: newVal }) + this.$store.dispatch('gui/console/saveSetting', { name: 'direction', value: newVal }) } get availableEntryStyles() { @@ -160,7 +160,7 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } set entryStyle(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'console.entryStyle', value: newVal }) + this.$store.dispatch('gui/console/saveSetting', { name: 'entryStyle', value: newVal }) } get consoleHeight() { @@ -168,7 +168,7 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } set consoleHeight(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'console.height', value: newVal }) + this.$store.dispatch('gui/console/saveSetting', { name: 'height', value: newVal }) } @Watch('consoleHeight') @@ -186,15 +186,15 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } set hideWaitTemperatures(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'console.hideWaitTemperatures', value: newVal }) + this.$store.dispatch('gui/console/saveSetting', { name: 'hideWaitTemperatures', value: newVal }) } get hideTimelapse() { - return this.$store.state.gui.console.hideTimelapse + return this.$store.state.gui.console.hideTlCommands } set hideTimelapse(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'console.hideTimelapse', value: newVal }) + this.$store.dispatch('gui/console/saveSetting', { name: 'hideTlCommands', value: newVal }) } existsPresetName(name: string) { @@ -215,7 +215,7 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { regex: filter.regex } - this.$store.dispatch('gui/consolefilters/update', { id: filter.id, values }) + this.$store.dispatch('gui/console/filterUpdate', { id: filter.id, values }) } createFilter() { @@ -240,16 +240,16 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) { } if (this.form.id) - this.$store.dispatch('gui/consolefilters/update', { id: this.form.id, values: filter }) + this.$store.dispatch('gui/console/filterUpdate', { id: this.form.id, values: filter }) else - this.$store.dispatch('gui/consolefilters/store', { values: filter }) + this.$store.dispatch('gui/console/filterStore', { values: filter }) this.clearForm() } } deleteFilter(id: string) { - this.$store.dispatch('gui/consolefilters/delete', id) + this.$store.dispatch('gui/console/filterDelete', id) } } \ No newline at end of file diff --git a/src/components/settings/SettingsControlTab.vue b/src/components/settings/SettingsControlTab.vue index 791c4ae1..195c7ed4 100644 --- a/src/components/settings/SettingsControlTab.vue +++ b/src/components/settings/SettingsControlTab.vue @@ -236,55 +236,55 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { } get controlStyle() { - return this.$store.state.gui.dashboard.control.style ?? 'bar' + return this.$store.state.gui.control.style ?? 'bar' } set controlStyle(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.style', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.style', value: newVal }) } get reverseX() { - return this.$store.state.gui.dashboard.control.reverseX + return this.$store.state.gui.control.reverseX } set reverseX(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.reverseX', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.reverseX', value: newVal }) } get reverseY() { - return this.$store.state.gui.dashboard.control.reverseY + return this.$store.state.gui.control.reverseY } set reverseY(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.reverseY', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.reverseY', value: newVal }) } get reverseZ() { - return this.$store.state.gui.dashboard.control.reverseZ + return this.$store.state.gui.control.reverseZ } set reverseZ(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.reverseZ', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.reverseZ', value: newVal }) } get feedrateXY() { - return this.$store.state.gui.dashboard.control.feedrateXY + return this.$store.state.gui.control.feedrateXY } set feedrateXY(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.feedrateXY', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.feedrateXY', value: newVal }) } get feedrateZ() { - return this.$store.state.gui.dashboard.control.feedrateZ + return this.$store.state.gui.control.feedrateZ } set feedrateZ(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.feedrateZ', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'control.feedrateZ', value: newVal }) } get stepsAll() { - const steps = this.$store.state.gui.dashboard.control.stepsAll + const steps = this.$store.state.gui.control.stepsAll return (steps ?? []).sort(function (a: number,b: number) { return b-a }) } @@ -292,11 +292,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absSteps = [] for(const value of newVal) absSteps.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.stepsAll', value: absSteps }) + this.$store.dispatch('gui/saveSetting', { name: 'control.stepsAll', value: absSteps }) } get stepsXY() { - const steps = this.$store.state.gui.dashboard.control.stepsXY + const steps = this.$store.state.gui.control.stepsXY return steps.sort(function (a: number,b: number) { return b-a }) } @@ -304,11 +304,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absSteps = [] for(const value of steps) absSteps.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.stepsXY', value: absSteps }) + this.$store.dispatch('gui/saveSetting', { name: 'control.stepsXY', value: absSteps }) } get stepsZ() { - const steps = this.$store.state.gui.dashboard.control.stepsZ + const steps = this.$store.state.gui.control.stepsZ return steps.sort(function (a: number,b: number) { return b-a }) } @@ -316,11 +316,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absSteps = [] for(const value of steps) absSteps.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.stepsZ', value: absSteps }) + this.$store.dispatch('gui/saveSetting', { name: 'control.stepsZ', value: absSteps }) } get stepsCircleXY() { - const steps = this.$store.state.gui.dashboard.control.stepsCircleXY + const steps = this.$store.state.gui.control.stepsCircleXY return steps.sort(function (a: number,b: number) { return b-a }) } @@ -328,11 +328,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absSteps = [] for(const value of steps) absSteps.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.stepsCircleXY', value: absSteps }) + this.$store.dispatch('gui/saveSetting', { name: 'control.stepsCircleXY', value: absSteps }) } get stepsCircleZ() { - const steps = this.$store.state.gui.dashboard.control.stepsCircleZ + const steps = this.$store.state.gui.control.stepsCircleZ return steps.sort(function (a: number,b: number) { return b-a }) } @@ -340,11 +340,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absSteps = [] for(const value of steps) absSteps.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.control.stepsCircleZ', value: absSteps }) + this.$store.dispatch('gui/saveSetting', { name: 'control.stepsCircleZ', value: absSteps }) } get feedamountsE() { - const steps = this.$store.state.gui.dashboard.extruder.feedamounts + const steps = this.$store.state.gui.control.extruder.feedamounts return steps.sort(function (a: number,b: number) { return b-a }) } @@ -352,11 +352,11 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absAmounts = [] for(const value of amounts) absAmounts.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.extruder.feedamounts', value: absAmounts }) + this.$store.dispatch('gui/saveSetting', { name: 'control.extruder.feedamounts', value: absAmounts }) } get feedratesE() { - const steps = this.$store.state.gui.dashboard.extruder.feedrates + const steps = this.$store.state.gui.control.extruder.feedrates return steps.sort(function (a: number,b: number) { return b-a }) } @@ -364,7 +364,7 @@ export default class SettingsControlTab extends Mixins(BaseMixin) { const absRates = [] for(const value of rates) absRates.push(Math.abs(value)) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.extruder.feedrates', value: absRates }) + this.$store.dispatch('gui/saveSetting', { name: 'control.extruder.feedrates', value: absRates }) } blurFeedrateXY() { diff --git a/src/components/settings/SettingsDashboardTabDesktop.vue b/src/components/settings/SettingsDashboardTabDesktop.vue index 090d2655..9c6517f9 100644 --- a/src/components/settings/SettingsDashboardTabDesktop.vue +++ b/src/components/settings/SettingsDashboardTabDesktop.vue @@ -37,7 +37,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -62,7 +62,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -124,7 +124,7 @@ export default class SettingsDashboardTabDesktop extends Mixins(DashboardMixin) changeState1(name: string, newVal: boolean) { const index = this.desktopLayout1.findIndex((element: any) => element.name === name) if (index !== -1) { - this.desktopLayout1[index].visable = newVal + this.desktopLayout1[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.desktopLayout1', value: this.desktopLayout1 }) } } @@ -132,7 +132,7 @@ export default class SettingsDashboardTabDesktop extends Mixins(DashboardMixin) changeState2(name: string, newVal: boolean) { const index = this.desktopLayout2.findIndex((element: any) => element.name === name) if (index !== -1) { - this.desktopLayout2[index].visable = newVal + this.desktopLayout2[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.desktopLayout2', value: this.desktopLayout2 }) } } diff --git a/src/components/settings/SettingsDashboardTabMobile.vue b/src/components/settings/SettingsDashboardTabMobile.vue index 2733748b..1588706b 100644 --- a/src/components/settings/SettingsDashboardTabMobile.vue +++ b/src/components/settings/SettingsDashboardTabMobile.vue @@ -37,7 +37,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -89,7 +89,7 @@ export default class SettingsDashboardTabMobile extends Mixins(DashboardMixin) { changeState(name: string, newVal: boolean) { const index = this.mobileLayout.findIndex((element: any) => element.name === name) if (index !== -1) { - this.mobileLayout[index].visable = newVal + this.mobileLayout[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.mobileLayout', value: this.mobileLayout }) } } diff --git a/src/components/settings/SettingsDashboardTabTablet.vue b/src/components/settings/SettingsDashboardTabTablet.vue index b2f13a6c..775eb735 100644 --- a/src/components/settings/SettingsDashboardTabTablet.vue +++ b/src/components/settings/SettingsDashboardTabTablet.vue @@ -37,7 +37,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -62,7 +62,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -124,7 +124,7 @@ export default class SettingsDashboardTabTablet extends Mixins(DashboardMixin) { changeState1(name: string, newVal: boolean) { const index = this.tabletLayout1.findIndex((element: any) => element.name === name) if (index !== -1) { - this.tabletLayout1[index].visable = newVal + this.tabletLayout1[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.tabletLayout1', value: this.tabletLayout1 }) } } @@ -132,7 +132,7 @@ export default class SettingsDashboardTabTablet extends Mixins(DashboardMixin) { changeState2(name: string, newVal: boolean) { const index = this.tabletLayout2.findIndex((element: any) => element.name === name) if (index !== -1) { - this.tabletLayout2[index].visable = newVal + this.tabletLayout2[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.tabletLayout2', value: this.tabletLayout2 }) } } diff --git a/src/components/settings/SettingsDashboardTabWidescreen.vue b/src/components/settings/SettingsDashboardTabWidescreen.vue index 1927d293..fa1a033c 100644 --- a/src/components/settings/SettingsDashboardTabWidescreen.vue +++ b/src/components/settings/SettingsDashboardTabWidescreen.vue @@ -37,7 +37,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -62,7 +62,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -87,7 +87,7 @@ {{ getPanelName(element.name) }} - mdi-checkbox-blank-outline + mdi-checkbox-blank-outline mdi-checkbox-marked @@ -159,7 +159,7 @@ export default class SettingsDashboardTabWidescreen extends Mixins(DashboardMixi changeState1(name: string, newVal: boolean) { const index = this.widescreenLayout1.findIndex((element: any) => element.name === name) if (index !== -1) { - this.widescreenLayout1[index].visable = newVal + this.widescreenLayout1[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.widescreenLayout1', value: this.widescreenLayout1 }) } } @@ -167,7 +167,7 @@ export default class SettingsDashboardTabWidescreen extends Mixins(DashboardMixi changeState2(name: string, newVal: boolean) { const index = this.widescreenLayout2.findIndex((element: any) => element.name === name) if (index !== -1) { - this.widescreenLayout2[index].visable = newVal + this.widescreenLayout2[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.widescreenLayout2', value: this.widescreenLayout2 }) } } @@ -175,7 +175,7 @@ export default class SettingsDashboardTabWidescreen extends Mixins(DashboardMixi changeState3(name: string, newVal: boolean) { const index = this.widescreenLayout3.findIndex((element: any) => element.name === name) if (index !== -1) { - this.widescreenLayout3[index].visable = newVal + this.widescreenLayout3[index].visible = newVal this.$store.dispatch('gui/saveSetting', {name: 'dashboard.widescreenLayout3', value: this.widescreenLayout3 }) } } diff --git a/src/components/settings/SettingsGeneralTab.vue b/src/components/settings/SettingsGeneralTab.vue index efa0c927..763ddd89 100644 --- a/src/components/settings/SettingsGeneralTab.vue +++ b/src/components/settings/SettingsGeneralTab.vue @@ -18,13 +18,71 @@ + + + {{ $t('Settings.GeneralTab.Backup') }} + {{ $t('Settings.GeneralTab.Restore') }} + + - {{ $t('Settings.GeneralTab.FactoryReset') }} + {{ $t('Settings.GeneralTab.FactoryReset') }} + + + + mdi-close-thick + + + + + {{ $t('Settings.GeneralTab.BackupDialog') }} + + + + + + + + + + + + + + + {{ $t('Settings.GeneralTab.Backup') }} + + + + + + - + mdi-close-thick @@ -36,68 +94,42 @@ + + + - - - - - - + @@ -105,8 +137,8 @@ {{ $t('Settings.GeneralTab.Reset') }} @@ -115,6 +147,44 @@ + + + + mdi-close-thick + + + + + {{ $t('Settings.GeneralTab.RestoreDialog') }} + + + + + + + + + + + + + {{ $t('Settings.GeneralTab.Restore') }} + + + + + + @@ -125,21 +195,74 @@ import { Mixins } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import SettingsRow from '@/components/settings/SettingsRow.vue' import Panel from '@/components/ui/Panel.vue' +import Vue from 'vue' + @Component({ components: {Panel, SettingsRow} }) export default class SettingsGeneralTab extends Mixins(BaseMixin) { + private dialogBackupMainsail = false private dialogResetMainsail = false - private dialogResetMainsailLoading = false - private dbCheckboxes = { - mainsail: false, - mainsail_presets: false, - mainsail_gcodehistory: false, - mainsail_macrogroups: false, - mainsail_remoteprinters: false, - timelapse: false, - history_jobs: false, - history_totals: false, + private dialogRestoreMainsail = false + + private dbCheckboxes: string[] = [] + + private restoreableNamespaces: { name: string, label: string}[] = [] + private restoreObjects: any = {} + + private mainsailKeys: { name: string, label: string}[] = [] + private availableNamespaces: string[] = [] + + $refs!: { + uploadBackupFile: HTMLInputElement + } + + get availableKeys() { + return [ + { + name: 'general', + label: this.$t('Settings.GeneralTab.General')+'' + }, { + name: 'console', + label: this.$t('Settings.ConsoleTab.Console')+'' + }, { + name: 'control', + label: this.$t('Settings.ControlTab.Control')+'' + }, { + name: 'dashboard', + label: this.$t('Settings.DashboardTab.Dashboard')+'' + }, { + name: 'editor', + label: this.$t('Settings.EditorTab.Editor')+'' + }, { + name: 'gcodeviewer', + label: this.$t('Settings.GCodeViewerTab.GCodeViewer')+'' + }, { + name: 'gcodehistory', + label: this.$t('Settings.GeneralTab.DbConsoleHistory')+'' + }, { + name: 'macros', + label: this.$t('Settings.MacrosTab.Macros')+'' + }, { + name: 'presets', + label: this.$t('Settings.PresetsTab.PreheatPresets')+'' + }, { + name: 'remoteprinters', + label: this.$t('Settings.RemotePrintersTab.RemotePrinters')+'' + }, { + name: 'timelapse', + label: this.$t('Settings.TimelapseTab.Timelapse')+'' + }, { + name: 'uiSettings', + label: this.$t('Settings.UiSettingsTab.UiSettings')+'' + }, { + name: 'view', + label: this.$t('Settings.GeneralTab.DbView')+'' + }, { + name: 'webcams', + label: this.$t('Settings.WebcamsTab.Webcams')+'' + } + ] } get printerName() { @@ -214,9 +337,145 @@ export default class SettingsGeneralTab extends Mixins(BaseMixin) { return this.$store.state.server.components ?? [] } - resetMainsail() { - this.$store.dispatch('gui/resetMoonrakerDB', this.dbCheckboxes) - this.dialogResetMainsailLoading = true + async refreshNamespaces() { + this.availableNamespaces = [] + + const url = this.$store.getters['socket/getUrl'] + '/server/database/list' + const response = await fetch(url) + if (response) { + const objects = await response.json() + this.availableNamespaces = [...objects.result?.namespaces] ?? [] + } + } + + async refreshMainsailKeys() { + this.mainsailKeys = [] + + const url = this.$store.getters['socket/getUrl'] + '/server/database/item?namespace=mainsail' + const response = await fetch(url) + if (response) { + const objects = await response.json() + if (objects?.result?.value) { + Object.keys(objects?.result?.value).forEach((tmp: string) => { + if (tmp !== 'initVersion') { + const namespace = this.availableKeys.find((namespace) => namespace.name === tmp) + const tmpNamespace = namespace ? namespace : { name: tmp, label: tmp } + this.mainsailKeys.push(tmpNamespace) + } + }) + + this.mainsailKeys = this.mainsailKeys.sort((a, b) => { + if (a.name === 'general') return -1 + if (b.name === 'general') return 1 + + const stringA = a.label.toString().toLowerCase() + const stringB = b.label.toString().toLowerCase() + + if (stringA < stringB) return -1 + if (stringA > stringB) return 1 + + return 0 + }) + } + } + } + + changeNamespace(name: string) { + if (this.dbCheckboxes.includes(name)) { + const index = this.dbCheckboxes.indexOf(name) + if (index >= 0) this.dbCheckboxes.splice(index, 1) + } else this.dbCheckboxes.push(name) + } + + async resetMainsail() { + await this.refreshNamespaces() + if (this.availableNamespaces.includes('mainsail')) await this.refreshMainsailKeys() + else this.mainsailKeys = [] + + this.dbCheckboxes = [] + this.dialogResetMainsail = true + } + + async resetMainsailAction() { + await this.$store.dispatch('socket/addLoading', 'resetMainsail') + await this.$store.dispatch('gui/resetMoonrakerDB', this.dbCheckboxes) + } + + async backupDb() { + this.$store.dispatch('socket/addLoading', 'backupDbButton') + await this.refreshNamespaces() + if (this.availableNamespaces.includes('mainsail')) await this.refreshMainsailKeys() + else this.mainsailKeys = [] + + this.dbCheckboxes = [] + this.dialogBackupMainsail = true + } + + async backupMainsail() { + await this.$store.dispatch('socket/addLoading', 'backupMainsail') + await this.$store.dispatch('gui/backupMoonrakerDB', this.dbCheckboxes) + await this.$store.dispatch('socket/removeLoading', 'backupMainsail') + this.dialogBackupMainsail = false + } + + async restoreDb() { + this.$store.dispatch('socket/addLoading', 'restoreUploadButton') + this.$refs?.uploadBackupFile?.click() + } + + uploadRestore() { + if (this.$refs.uploadBackupFile.files?.length) { + const backup = this.$refs.uploadBackupFile.files[0] + if (backup) { + const reader = new FileReader() + reader.readAsText(backup, 'UTF-8') + reader.onload = (evt) => { + this.restoreableNamespaces = [] + try { + this.restoreObjects = JSON.parse(evt?.target?.result+'') + + Object.keys(this.restoreObjects).forEach((tmp: string) => { + const namespace = this.availableKeys.find((namespace) => namespace.name === tmp) + const tmpNamespace = namespace ? namespace : { name: tmp, label: tmp } + + this.restoreableNamespaces.push(tmpNamespace) + }) + + this.restoreableNamespaces = this.restoreableNamespaces.sort((a, b) => { + if (a.name === 'general') return -1 + if (b.name === 'general') return 1 + + const stringA = a.label.toString().toLowerCase() + const stringB = b.label.toString().toLowerCase() + + if (stringA < stringB) return -1 + if (stringA > stringB) return 1 + + return 0 + }) + + this.dbCheckboxes = [] + this.dialogRestoreMainsail = true + } catch (e) { + Vue.$toast.error(this.$t('Settings.GeneralTab.CannotReadJson')+'') + } + } + reader.onerror = (evt) => { + window.console.error(evt) + } + } + + this.$refs.uploadBackupFile.value = '' + } + } + + async restoreDbAction () { + this.$store.dispatch('socket/addLoading', 'restoreDbAction') + + this.$store.dispatch('gui/restoreMoonrakerDB', { + dbCheckboxes: this.dbCheckboxes, + restoreObjects: this.restoreObjects + }) } } \ No newline at end of file diff --git a/src/components/settings/SettingsMacrosTab.vue b/src/components/settings/SettingsMacrosTab.vue index 6510fd50..9d1fb38d 100644 --- a/src/components/settings/SettingsMacrosTab.vue +++ b/src/components/settings/SettingsMacrosTab.vue @@ -4,11 +4,11 @@ {{ $t('Settings.MacrosTab.General') }} - + - + @@ -30,7 +30,7 @@ import SettingsMacrosTabExpert from '@/components/settings/SettingsMacrosTabExpe export default class SettingsMacrosTab extends Mixins(BaseMixin) { private showGeneral = true - get macroManagements() { + get modes() { return [ { text: this.$t('Settings.MacrosTab.Simple'), @@ -43,12 +43,12 @@ export default class SettingsMacrosTab extends Mixins(BaseMixin) { ] } - get macroManagement() { - return this.$store.state.gui?.dashboard?.macroManagement ?? 'simple' + get mode() { + return this.$store.state.gui?.macros?.mode ?? 'simple' } - set macroManagement(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.macroManagement', value: newVal }) + set mode(newVal) { + this.$store.dispatch('gui/macros/saveSetting', { name: 'mode', value: newVal }) } updateShowGeneral(newVal: boolean) { diff --git a/src/components/settings/SettingsMacrosTabExpert.vue b/src/components/settings/SettingsMacrosTabExpert.vue index 338e600a..126bbf7a 100644 --- a/src/components/settings/SettingsMacrosTabExpert.vue +++ b/src/components/settings/SettingsMacrosTabExpert.vue @@ -192,7 +192,7 @@ import draggable from 'vuedraggable' import SettingsRow from '@/components/settings/SettingsRow.vue' import {Debounce} from 'vue-debounce-decorator' import {PrinterStateMacro} from '@/store/printer/types' -import {GuiMacrogroupsStateMacrogroup, GuiMacrogroupsStateMacrogroupMacro} from '@/store/gui/macrogroups/types' +import {GuiMacrosStateMacrogroup, GuiMacrosStateMacrogroupMacro} from '@/store/gui/macros/types' @Component({ components: {SettingsRow, draggable} @@ -253,24 +253,24 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { } get availableMacros() { - return this.allMacros.filter((m: GuiMacrogroupsStateMacrogroupMacro) => !this.editGroupUsedMacros.includes(m.name)) + return this.allMacros.filter((m: GuiMacrosStateMacrogroupMacro) => !this.editGroupUsedMacros.includes(m.name)) } get groups() { - return this.$store.getters['gui/macrogroups/getAllMacrogroups'] ?? [] + return this.$store.getters['gui/macros/getAllMacrogroups'] ?? [] } get editGroupUsedMacros() { - return this.editGroup?.macros?.map((m: GuiMacrogroupsStateMacrogroupMacro) => m.name) ?? [] + return this.editGroup?.macros?.map((m: GuiMacrosStateMacrogroupMacro) => m.name) ?? [] } - get editGroup(): GuiMacrogroupsStateMacrogroup | null { - return this.$store.getters['gui/macrogroups/getMacrogroup'](this.editGroupId) + get editGroup(): GuiMacrosStateMacrogroup | null { + return this.$store.getters['gui/macros/getMacrogroup'](this.editGroupId) } get editGroupMacros() { const macros = this.editGroup?.macros ?? [] - macros.sort((a: GuiMacrogroupsStateMacrogroupMacro, b: GuiMacrogroupsStateMacrogroupMacro) => a.pos - b.pos) + macros.sort((a: GuiMacrosStateMacrogroupMacro, b: GuiMacrosStateMacrogroupMacro) => a.pos - b.pos) return macros } @@ -280,7 +280,7 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { } existsGroupName(name: string) { - return (this.groups.findIndex((group: GuiMacrogroupsStateMacrogroup) => group.name === name && group.id != this.editGroupId) >= 0) + return (this.groups.findIndex((group: GuiMacrosStateMacrogroup) => group.name === name && group.id != this.editGroupId) >= 0) } clearColorObject(color: any): string { @@ -304,29 +304,29 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { showInPause: true, showInPrinting: true, } - this.editGroupId = await this.$store.dispatch('gui/macrogroups/store', { values }) + this.editGroupId = await this.$store.dispatch('gui/macros/groupStore', { values }) this.boolFormEdit = true } - editMacrogroup(group: GuiMacrogroupsStateMacrogroup) { + editMacrogroup(group: GuiMacrosStateMacrogroup) { this.boolFormEdit = true this.editGroupId = group.id } deleteMacrogroup(id: string) { - this.$store.dispatch('gui/macrogroups/delete', id) + this.$store.dispatch('gui/macros/groupDelete', id) } addMacroToGroup(macro: PrinterStateMacro) { - this.$store.dispatch('gui/macrogroups/addMacroToMacrogroup', { + this.$store.dispatch('gui/macros/addMacroToMacrogroup', { id: this.editGroupId, macro: macro.name }) } - updateMacroFromGroup(macro: GuiMacrogroupsStateMacrogroupMacro, option: string, value: boolean | string | number) { - this.$store.dispatch('gui/macrogroups/updateMacroFromMacrogroup', { + updateMacroFromGroup(macro: GuiMacrosStateMacrogroupMacro, option: string, value: boolean | string | number) { + this.$store.dispatch('gui/macros/updateMacroFromMacrogroup', { id: this.editGroupId, macro: macro.name, option: option, @@ -344,7 +344,7 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { this.updateMacroFromGroup(this.editGroupMacros[newIndex], 'pos', oldPos) } - changeColorMacroFromGroup(macro: GuiMacrogroupsStateMacrogroupMacro) { + changeColorMacroFromGroup(macro: GuiMacrosStateMacrogroupMacro) { let index = this.macroColors.findIndex((color) => color.value === macro.color) + 1 const maxIndex = this.macroColors.length - 1 @@ -354,8 +354,8 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { this.updateMacroFromGroup(macro, 'color', newColor) } - removeMacroFromGroup(macro: GuiMacrogroupsStateMacrogroupMacro) { - this.$store.dispatch('gui/macrogroups/removeMacroFromMacrogroup', { + removeMacroFromGroup(macro: GuiMacrosStateMacrogroupMacro) { + this.$store.dispatch('gui/macros/removeMacroFromMacrogroup', { id: this.editGroupId, macro: macro.name }) @@ -376,7 +376,7 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) { const values:any = {} values[option] = newVal - this.$store.dispatch('gui/macrogroups/update', { + this.$store.dispatch('gui/macros/groupUpdate', { id: this.editGroupId, values }) diff --git a/src/components/settings/SettingsMacrosTabSimple.vue b/src/components/settings/SettingsMacrosTabSimple.vue index 0ea9e83d..30d127b7 100644 --- a/src/components/settings/SettingsMacrosTabSimple.vue +++ b/src/components/settings/SettingsMacrosTabSimple.vue @@ -34,7 +34,7 @@ export default class SettingsMacrosTabSimple extends Mixins(BaseMixin) { } get hiddenMacros() { - return this.$store.state.gui.dashboard.hiddenMacros ?? [] + return this.$store.state.gui.macros.hiddenMacros ?? [] } getMacroStatus(name: string) { @@ -49,7 +49,7 @@ export default class SettingsMacrosTabSimple extends Mixins(BaseMixin) { else hiddenMacros.push(name.toUpperCase()) - this.$store.dispatch('gui/saveSetting', { name: 'dashboard.hiddenMacros', value: hiddenMacros }) + this.$store.dispatch('gui/macros/saveSetting', { name: 'hiddenMacros', value: hiddenMacros }) } } \ No newline at end of file diff --git a/src/components/settings/SettingsPresetsTab.vue b/src/components/settings/SettingsPresetsTab.vue index ea7b8c7a..6bb28b54 100644 --- a/src/components/settings/SettingsPresetsTab.vue +++ b/src/components/settings/SettingsPresetsTab.vue @@ -306,7 +306,7 @@ export default class SettingsPresetsTab extends Mixins(BaseMixin) { saveCooldown() { if (this.cooldownForm.valid) { - this.$store.dispatch('gui/presets/updateCooldownGcode', this.cooldownForm.gcode) + this.$store.dispatch('gui/presets/saveSetting', { name: 'cooldownGcode', value: this.cooldownForm.gcode }) this.cooldownForm.bool = false } } diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 475e7bfd..3e691aea 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -115,95 +115,95 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin) { private defaultPrimaryColor = defaultPrimaryColor get logoColor() { - return this.$store.state.gui.theme.logo + return this.$store.state.gui.uiSettings.logo } set logoColor(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'theme.logo', value: newVal}) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.logo', value: newVal}) } get primaryColor() { - return this.$store.state.gui.theme.primary + return this.$store.state.gui.uiSettings.primary } set primaryColor(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'theme.primary', value: newVal}) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.primary', value: newVal}) } get boolBigThumbnail() { - return this.$store.state.gui.dashboard.boolBigThumbnail + return this.$store.state.gui.uiSettings.boolBigThumbnail } set boolBigThumbnail(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'dashboard.boolBigThumbnail', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.boolBigThumbnail', value: newVal }) } get boolWebcamInNavigation() { - return this.$store.state.gui.webcamSettings.boolNavi ?? false + return this.$store.state.gui.uiSettings.boolWebcamNavi ?? false } set boolWebcamInNavigation(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'webcamSettings.boolNavi', value: newVal }) + this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.boolWebcamNavi', value: newVal }) } get displayCancelPrint() { - return this.$store.state.gui.general.displayCancelPrint + return this.$store.state.gui.uiSettings.displayCancelPrint } set displayCancelPrint(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'general.displayCancelPrint', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.displayCancelPrint', value: newVal }) } get displayZOffsetStandby() { - return this.$store.state.gui.general.displayZOffsetStandby + return this.$store.state.gui.uiSettings.displayZOffsetStandby } set displayZOffsetStandby(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'general.displayZOffsetStandby', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.displayZOffsetStandby', value: newVal }) } get confirmOnEmergencyStop() { - return this.$store.state.gui.general.confirmOnEmergencyStop + return this.$store.state.gui.uiSettings.confirmOnEmergencyStop } set confirmOnEmergencyStop(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'general.confirmOnEmergencyStop', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.confirmOnEmergencyStop', value: newVal }) } get confirmOnPowerDeviceChange() { - return this.$store.state.gui.general.confirmOnPowerDeviceChange + return this.$store.state.gui.uiSettings.confirmOnPowerDeviceChange } set confirmOnPowerDeviceChange(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'general.confirmOnPowerDeviceChange', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.confirmOnPowerDeviceChange', value: newVal }) } get lockSliders() { - return this.$store.state.gui.general.lockSlidersOnTouchDevices + return this.$store.state.gui.uiSettings.lockSlidersOnTouchDevices } set lockSliders(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'general.lockSlidersOnTouchDevices', value: newVal}) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.lockSlidersOnTouchDevices', value: newVal}) } get lockSlidersDelay() { - return this.$store.state.gui.general.lockSlidersDelay + return this.$store.state.gui.uiSettings.lockSlidersDelay } set lockSlidersDelay(newVal) { - (newVal >= 0) ? this.$store.dispatch('gui/saveSetting', {name: 'general.lockSlidersDelay', value: newVal}) : {} + (newVal >= 0) ? this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.lockSlidersDelay', value: newVal}) : {} } get boolWideNavDrawer() { - return this.$store.state.gui.dashboard.boolWideNavDrawer ?? false + return this.$store.state.gui.uiSettings.boolWideNavDrawer ?? false } get navigationStyleSetting() { - return this.$store.state.gui.dashboard.navigationStyle + return this.$store.state.gui.uiSettings.navigationStyle } set navigationStyleSetting(newVal) { - this.$store.dispatch('gui/saveSetting', {name: 'dashboard.navigationStyle', value: newVal }) + this.$store.dispatch('gui/saveSetting', {name: 'uiSettings.navigationStyle', value: newVal }) } get navigationStyles() { @@ -220,7 +220,7 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin) { } get boolHideUploadAndPrintButton() { - return this.$store.state.gui.dashboard.boolHideUploadAndPrintButton ?? false + return this.$store.state.gui.uiSettings.boolHideUploadAndPrintButton ?? false } set boolHideUploadAndPrintButton(newVal) { diff --git a/src/locales/en.json b/src/locales/en.json index 4e205947..5f916010 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -605,15 +605,18 @@ "FactoryReset": "Factory reset", "FactoryDialog": "Please select all the sections you want to reset:", "Reset": "reset", - "DbGeneral": "General", - "DbPresets": "Presets", - "DbGcodehistry": "G-Code History", - "DbMacrogroups": "Macrogroups", - "DbRemoteprinters": "Remoteprinters", + "DbConsoleHistory": "Console History", + "DbView": "View Settings", "DbHistoryJobs": "History Jobs", "DbHistoryTotals": "History Totals", "DbWebcams": "Webcams", - "DbTimelapseSettings": "Timelapse Settings" + "DbTimelapseSettings": "Timelapse Settings", + "MoonrakerDb": "Moonraker DB", + "Backup": "Backup", + "BackupDialog": "Please select all the sections you want to create a backup:", + "Restore": "Restore", + "CannotReadJson": "Cannot read/parse backup file.", + "RestoreDialog": "Please select all the sections you want to restore:" }, "WebcamsTab": { "Webcams": "Webcams", @@ -724,6 +727,7 @@ "Management": "Management", "Simple": "Simple", "Expert": "Expert", + "Group": "Group", "NoGroups": "No group found...", "Macrogroups": "Groups", "EditGroup": "Edit Group", diff --git a/src/pages/Console.vue b/src/pages/Console.vue index 970c1e10..3a48744e 100644 --- a/src/pages/Console.vue +++ b/src/pages/Console.vue @@ -150,7 +150,7 @@ export default class PageConsole extends Mixins(BaseMixin) { } get lastCommands(): string[] { - return this.$store.state.gui.gcodehistory.history ?? [] + return this.$store.state.gui.gcodehistory.entries ?? [] } commandClick(msg: string): void { diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index 8466afd0..36f08aa5 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -97,7 +97,7 @@ export default class PageDashboard extends Mixins(DashboardMixin) { get mobileLayout() { let panels = this.$store.getters['gui/getPanels']('mobileLayout') panels = panels.concat(this.missingPanelsMobile) - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } @@ -105,14 +105,14 @@ export default class PageDashboard extends Mixins(DashboardMixin) { get tabletLayout1() { let panels = this.$store.getters['gui/getPanels']('tabletLayout1') panels = panels.concat(this.missingPanelsTablet) - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } get tabletLayout2() { let panels = this.$store.getters['gui/getPanels']('tabletLayout2') - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } @@ -120,14 +120,14 @@ export default class PageDashboard extends Mixins(DashboardMixin) { get desktopLayout1() { let panels = this.$store.getters['gui/getPanels']('desktopLayout1') panels = panels.concat(this.missingPanelsDesktop) - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } get desktopLayout2() { let panels = this.$store.getters['gui/getPanels']('desktopLayout2') - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } @@ -135,21 +135,21 @@ export default class PageDashboard extends Mixins(DashboardMixin) { get widescreenLayout1() { let panels = this.$store.getters['gui/getPanels']('widescreenLayout1') panels = panels.concat(this.missingPanelsWidescreen) - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } get widescreenLayout2() { let panels = this.$store.getters['gui/getPanels']('widescreenLayout2') - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } get widescreenLayout3() { let panels = this.$store.getters['gui/getPanels']('widescreenLayout3') - panels = panels.filter((element: any) => element.visable) + panels = panels.filter((element: any) => element.visible) return panels } diff --git a/src/store/farm/printer/getters.ts b/src/store/farm/printer/getters.ts index 36256144..1841f507 100644 --- a/src/store/farm/printer/getters.ts +++ b/src/store/farm/printer/getters.ts @@ -43,7 +43,7 @@ export const getters: GetterTree = { }, getLogoColor: (state) => { - return state.data.gui?.theme?.logo ?? defaultLogoColor + return state.data.gui?.uiSettings?.logo ?? defaultLogoColor }, getStatus: (state, getters) => { diff --git a/src/store/gui/actions.ts b/src/store/gui/actions.ts index d413613b..fd66eccf 100644 --- a/src/store/gui/actions.ts +++ b/src/store/gui/actions.ts @@ -3,10 +3,16 @@ import {ActionTree} from 'vuex' import {GuiState} from '@/store/gui/types' import {RootState} from '@/store/types' import { getDefaultState } from './index' +import {themeDir} from '@/store/variables' export const actions: ActionTree = { - reset({ commit }) { + reset({ commit, dispatch }) { commit('reset') + + dispatch('console/reset') + dispatch('gcodehistory/reset') + dispatch('macros/reset') + dispatch('presets/reset') }, init() { @@ -15,107 +21,73 @@ export const actions: ActionTree = { }, initStore({ commit, dispatch, rootState }, payload) { - - //added in V2.1.0 - if ( - payload.value.dashboard?.control !== undefined && - 'useCross' in payload.value.dashboard?.control - ) { - dispatch('saveSetting', { name: 'dashboard.control.style', value: 'cross' }) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'dashboard.control.useCross' }) - delete payload.value.dashboard?.control.useCross - } - - //added in V2.1.0 - if (payload.value.webcam) { - window.console.debug('convert old webcams') - - if (payload.value.webcam.configs && payload.value.webcam.configs.length) { - payload.value.webcam.configs.forEach((oldWebcam: any) => { - const newWebcam = {...oldWebcam, urlStream: oldWebcam.url, urlSnapshot: oldWebcam.url.replace('action=stream', 'action=snapshot')} - delete newWebcam.url - dispatch('webcam/store', { values: newWebcam }) - }) - } - - commit('saveSetting', { name: 'webcamSettings.boolNavi', value: payload.value.webcam.boolNavi }) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'webcam' }) - } - - //added in V2.1.0 - if (payload.value.presets) { - window.console.debug('convert old presets') - - if (payload.value.presets && payload.value.presets.length) { - payload.value.presets.forEach((oldPreset: any) => { - dispatch('presets/store', { values: oldPreset }) - }) - - delete payload.value.presets - } - - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'presets' }) - } - - //added in V2.1.0 - if (payload.value.cooldownGcode) { - window.console.debug('convert old cooldownGcode') - - dispatch('presets/updateCooldownGcode', payload.value.cooldownGcode) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'cooldownGcode' }) - delete payload.value.cooldownGcode - } - - //added in V2.1.0 - if (payload.value.console?.customFilters) { - window.console.debug('convert old consolefilters') - - if (payload.value.console.customFilters && payload.value.console.customFilters.length) { - payload.value.console.customFilters.forEach((oldFilter: any) => { - dispatch('consolefilters/store', {values: oldFilter}) - }) - } - - delete payload.value.console.customFilters - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'console.customFilters' }) - } - - //added in V2.1.0 - if (payload.value.remote_printers) { - if (!rootState.socket?.remoteMode) { - window.console.debug('convert old remotePrinters') - - payload.value.remote_printers.forEach((printer: any) => { - const values = { - hostname: printer.hostname ?? '', - port: printer.port ?? 7125, - settings: printer.settings ?? {}, - } - dispatch('remoteprinters/store', { values }) - }) - - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'remote_printers' }) - } - - delete payload.value.remote_printers - } - - //added in V2.1.0 - if (payload.value.dashboard?.macrogroups) { - window.console.debug('convert old macrogroups') - - payload.value.dashboard?.macrogroups.forEach((macrogroup: any) => { - dispatch('macrogroups/store', { values: macrogroup }) - }) - - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'dashboard.macrogroups' }) - - delete payload.value.dashboard.macrogroups + if ('remoteprinters' in payload.value) { + if (!rootState.socket?.remoteMode) dispatch('remoteprinters/initStore', payload.value.remoteprinters.printers) + delete payload.value.remoteprinters } commit('setData', payload.value) }, + /* + * Create mainsail namespace in moonraker DB and fill in default values + */ + async initDb({ dispatch, rootGetters }) { + const baseUrl = rootGetters['socket/getUrl'] + '/server/database/item' + + const urlDefault = rootGetters['socket/getUrl'] + '/server/files/config/' + themeDir + '/default.json?time=' + Date.now() + const responseDefault = await fetch(urlDefault) + let defaults: any = {} + if (responseDefault) { + defaults = await responseDefault.json() + if (defaults.error?.code === 404) defaults = {} + } + + for (const key in defaults) { + if (['webcams', 'timelapse'].includes(key)) { + for (const key2 of defaults[key]) { + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: key, + key: key2, + value: defaults[key][key2] + }) + }) + } + } else { + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: 'mainsail', + key: key, + value: defaults[key] + }) + }) + } + } + + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: 'mainsail', + key: 'initVersion', + value: rootGetters['getVersion'] + }) + }) + + dispatch('init') + }, + saveSetting({ commit }, payload) { commit('saveSetting', payload) @@ -139,7 +111,7 @@ export const actions: ActionTree = { commit('setGcodefilesMetadata', data) dispatch('updateSettings', { keyName: 'gcodefiles', - newVal: state.gcodefiles + newVal: state.view.gcodefiles }) }, @@ -147,7 +119,7 @@ export const actions: ActionTree = { commit('setGcodefilesShowHiddenFiles', data) dispatch('updateSettings', { keyName: 'gcodefiles', - newVal: state.gcodefiles + newVal: state.view.gcodefiles }) }, @@ -155,66 +127,188 @@ export const actions: ActionTree = { commit('setCurrentWebcam', payload) dispatch('updateSettings', { keyName: 'webcamSettings.currentCam', - newVal: state.webcamSettings.currentCam + newVal: state.view.webcam.currentCam }) }, setTempchartDatasetAdditionalSensorSetting({ commit, dispatch, state }, payload) { commit('setTempchartDatasetAdditionalSensorSetting', payload) dispatch('updateSettings', { - keyName: 'tempchart', - newVal: state.tempchart + keyName: 'view.tempchart', + newVal: state.view.tempchart }) }, - async resetMoonrakerDB({ commit, dispatch }, payload) { - await commit('setResetDatabases', payload) - dispatch('resetMoonrakerDbLoop') - }, + async resetMoonrakerDB({ commit, dispatch, rootGetters }, payload) { + const baseUrl = rootGetters['socket/getUrl'] + '/server/database/item' - async resetMoonrakerDbLoop({ state, commit }) { - if (state.resetDatabases.length) { - const namespace = state.resetDatabases[0] - - if (namespace.startsWith('mainsail') || ['webcams', 'timelapse'].includes(namespace)) { - Vue.$socket.emit('server.database.get_item', { namespace: namespace }, { action: 'gui/resetMoonrakerDbLoopItems' }) - } else if (namespace === 'history_jobs') { - Vue.$socket.emit('server.history.delete_job', { all: true }, { action: 'gui/resetMoonrakerDbLoopItems' }) - } else if (namespace === 'history_totals') { - Vue.$socket.emit('server.history.reset_totals', { }, { action: 'gui/resetMoonrakerDbLoopItems' }) - } - - await commit('removeResetDatabase', namespace) - } else window.location.reload() - }, - - resetMoonrakerDbLoopItems({ dispatch }, payload) { - if ('value' in payload && Object.keys(payload.value).length) { - Object.keys(payload.value).forEach(key => { - Vue.$socket.emit('server.database.delete_item', { namespace: payload.namespace, key: key }) - }) + const urlDefault = rootGetters['socket/getUrl'] + '/server/files/config/' + themeDir + '/default.json?time=' + Date.now() + const responseDefault = await fetch(urlDefault) + let defaults: any = {} + if (responseDefault) { + defaults = await responseDefault.json() + if (defaults.error?.code === 404) defaults = {} } - dispatch('resetMoonrakerDbLoop') + for (const key of payload) { + if (['webcams', 'timelapse'].includes(key)) { + const url = baseUrl + '?namespace=' + key + + const response = await fetch(url) + const objects = await response.json() + if (objects?.result?.value) { + for (const item of Object.keys(objects?.result?.value)) { + await fetch(url+'&key='+item, { method: 'DELETE' }) + } + } + + if (key in defaults) { + for (const key2 of defaults[key]) { + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: key, + key: key2, + value: defaults[key][key2] + }) + }) + } + } + } else if (key === 'history_jobs') { + await fetch(rootGetters['socket/getUrl'] + '/server/history/job?all=true', { method: 'DELETE' }) + } else if (key === 'history_totals') { + await fetch(rootGetters['socket/getUrl'] + '/server/history/reset_totals', { method: 'POST' }) + } else { + await fetch(rootGetters['socket/getUrl'] + '/server/database/item?namespace=mainsail&key=' + key, { method: 'DELETE' }) + + if (key in defaults) { + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: 'mainsail', + key: key, + value: defaults[key] + }) + }) + } + } + } + + window.location.reload() + }, + + async backupMoonrakerDB({ commit, dispatch, rootGetters }, payload) { + const backup: any = {} + + const responseMainsail = await fetch(rootGetters['socket/getUrl'] + '/server/database/item?namespace=mainsail') + const objectsMainsail = await responseMainsail.json() + const mainsailDb = objectsMainsail?.result?.value ?? {} + + for (const key of payload) { + if (['timelapse', 'webcams'].includes(key)) { + const url = rootGetters['socket/getUrl'] + '/server/database/item?namespace=' + key + + const response = await fetch(url) + const objects = await response.json() + if (objects?.result?.value) backup[key] = {...objects?.result?.value} + } else if (key in mainsailDb) { + backup[key] = {...mainsailDb[key]} + } + } + + const element = document.createElement('a') + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(backup))) + element.setAttribute('download', 'backup-mainsail.json') + element.style.display = 'none' + document.body.appendChild(element) + element.click() + + document.body.removeChild(element) + }, + + async restoreMoonrakerDB({ rootGetters }, payload) { + const baseUrl = rootGetters['socket/getUrl'] + '/server/database/item' + const mainsailUrl = baseUrl + '?namespace=mainsail' + const responseNamespaces = await fetch(rootGetters['socket/getUrl'] + '/server/database/list') + const objectsNamespaces = await responseNamespaces.json() + const namespacesArray = objectsNamespaces?.result?.namespaces ?? [] + let mainsailArray: string[] = [] + + if (namespacesArray.includes('mainsail')) { + const responseMainsail = await fetch(mainsailUrl) + const objectsMainsail = await responseMainsail.json() + mainsailArray = Object.keys(objectsMainsail?.result?.value ?? {}) + } + + for (const key of payload.dbCheckboxes) { + if (['timelapse', 'webcams'].includes(key)) { + if (namespacesArray.includes(key)) { + const url = baseUrl + '?namespace=' + key + const response = await fetch(url) + const objects = await response.json() + if (objects?.result?.value) { + for (const item of Object.keys(objects?.result?.value)) { + await fetch(url + '&key=' + item, {method: 'DELETE'}) + } + } + } + + for (const key2 of Object.keys(payload.restoreObjects[key])) { + const value = payload.restoreObjects[key][key2] + await fetch(baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: key, + key: key2, + value + }) + }) + } + } else { + if (mainsailArray.includes(key)) await fetch(mainsailUrl+'&key='+key, { method: 'DELETE' }) + await fetch(mainsailUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + namespace: 'mainsail', + key, + value: payload.restoreObjects[key] + }) + }) + } + } + + window.location.reload() }, setHistoryColumns({ commit, dispatch, state }, data) { commit('setHistoryColumns', data) dispatch('updateSettings', { - keyName: 'history', - newVal: state.history + keyName: 'view.history', + newVal: state.view.history }) }, hideStatusInHistoryList({ commit, dispatch, state }, name) { - const array: string[] = [...state.history.hidePrintStatus] + const array: string[] = [...state.view.history.hidePrintStatus] if (!array.includes(name)) { array.push(name) commit('setHistoryHidePrintStatus', array) dispatch('updateSettings', { - keyName: 'history.hidePrintStatus', + keyName: 'view.history.hidePrintStatus', newVal: array }) } @@ -231,7 +325,7 @@ export const actions: ActionTree = { }, showStatusInHistoryList({ commit, dispatch, state }, name) { - const array: string[] = [...state.history.hidePrintStatus] + const array: string[] = [...state.view.history.hidePrintStatus] const index = array.indexOf(name) if (index !== -1) { @@ -239,7 +333,7 @@ export const actions: ActionTree = { commit('setHistoryHidePrintStatus', array) dispatch('updateSettings', { - keyName: 'history.hidePrintStatus', + keyName: 'view.history.hidePrintStatus', newVal: array }) } @@ -247,7 +341,7 @@ export const actions: ActionTree = { resetLayout({ dispatch }, name) { const defaultState = getDefaultState() - // eslint-disable-next-line + // @ts-ignore const newVal: any = defaultState.dashboard[name] ?? [] dispatch('saveSetting', { @@ -259,8 +353,8 @@ export const actions: ActionTree = { toggleHideUploadAndPrintBtn({commit, dispatch, state}, payload) { commit('toggleHideUploadAndPrintBtn', payload) dispatch('updateSettings', { - keyName: 'dashboard.boolHideUploadAndPrintButton', - newVal: state.dashboard.boolHideUploadAndPrintButton + keyName: 'uiSettings.boolHideUploadAndPrintButton', + newVal: state.uiSettings.boolHideUploadAndPrintButton }) } } \ No newline at end of file diff --git a/src/store/gui/console/actions.ts b/src/store/gui/console/actions.ts new file mode 100644 index 00000000..da15435b --- /dev/null +++ b/src/store/gui/console/actions.ts @@ -0,0 +1,45 @@ +import { ActionTree } from 'vuex' +import {RootState} from '@/store/types' +import { v4 as uuidv4 } from 'uuid' +import Vue from 'vue' +import {GuiConsoleState} from '@/store/gui/console/types' + +export const actions: ActionTree = { + reset({ commit }) { + commit('reset') + }, + + saveSetting({ dispatch }, payload) { + dispatch('gui/saveSetting', { + name: 'console.'+payload.name, + value: payload.value + }, { root: true }) + }, + + filterUpload(_, payload) { + Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'console.consolefilters.'+payload.id, value: payload.value }) + }, + + filterStore({ commit, dispatch, state }, payload) { + const id = uuidv4() + + commit('filterStore', { id, values: payload.values }) + dispatch('filterUpload', { + id, + value: state.consolefilters[id] + }) + }, + + filterUpdate({ commit, dispatch, state }, payload) { + commit('filterUpdate', payload) + dispatch('filterUpload', { + id: payload.id, + value: state.consolefilters[payload.id] + }) + }, + + filterDelete({ commit }, payload) { + commit('filterDelete', payload) + Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'console.consolefilters.'+payload }) + }, +} \ No newline at end of file diff --git a/src/store/gui/consolefilters/getters.ts b/src/store/gui/console/getters.ts similarity index 82% rename from src/store/gui/consolefilters/getters.ts rename to src/store/gui/console/getters.ts index 0e3e0faf..4bef524a 100644 --- a/src/store/gui/consolefilters/getters.ts +++ b/src/store/gui/console/getters.ts @@ -1,13 +1,13 @@ import { GetterTree } from 'vuex' -import {GuiConsolefiltersState, GuiConsolefiltersStateFilter} from '@/store/gui/consolefilters/types' +import {GuiConsoleState, GuiConsoleStateFilter} from '@/store/gui/console/types' import {caseInsensitiveSort} from '@/plugins/helpers' import {timelapseConsoleFilters} from '@/store/variables' // eslint-disable-next-line -export const getters: GetterTree = { +export const getters: GetterTree = { getConsolefilters:(state) => { - const consolefilters: GuiConsolefiltersStateFilter[] = [] + const consolefilters: GuiConsoleStateFilter[] = [] Object.keys(state.consolefilters).forEach((id: string) => { consolefilters.push({...state.consolefilters[id], id}) diff --git a/src/store/gui/console/index.ts b/src/store/gui/console/index.ts new file mode 100644 index 00000000..e080b72a --- /dev/null +++ b/src/store/gui/console/index.ts @@ -0,0 +1,28 @@ +import { Module } from 'vuex' +import { actions } from '@/store/gui/console/actions' +import { mutations } from '@/store/gui/console/mutations' +import { getters } from '@/store/gui/console/getters' +import {GuiConsoleState} from '@/store/gui/console/types' + +export const getDefaultState = (): GuiConsoleState => { + return { + hideWaitTemperatures: true, + hideTlCommands: true, + direction: 'table', + entryStyle: 'default', + height: 300, + consolefilters: {}, + } +} + +// initial state +const state = getDefaultState() + +// eslint-disable-next-line +export const console: Module = { + namespaced: true, + state, + getters, + actions, + mutations +} \ No newline at end of file diff --git a/src/store/gui/consolefilters/mutations.ts b/src/store/gui/console/mutations.ts similarity index 65% rename from src/store/gui/consolefilters/mutations.ts rename to src/store/gui/console/mutations.ts index c936ef05..dd8cb8bf 100644 --- a/src/store/gui/consolefilters/mutations.ts +++ b/src/store/gui/console/mutations.ts @@ -1,22 +1,18 @@ import { getDefaultState } from './index' import {MutationTree} from 'vuex' import Vue from 'vue' -import {GuiConsolefiltersState} from '@/store/gui/consolefilters/types' +import {GuiConsoleState} from '@/store/gui/console/types' -export const mutations: MutationTree = { +export const mutations: MutationTree = { reset(state) { Object.assign(state, getDefaultState()) }, - initStore(state, payload) { - Vue.set(state, 'consolefilters', payload.value) - }, - - store(state, payload) { + filterStore(state, payload) { Vue.set(state.consolefilters, payload.id, payload.values) }, - update(state, payload) { + filterUpdate(state, payload) { if (payload.id in state.consolefilters) { const preset = {...state.consolefilters[payload.id]} Object.assign(preset, payload.values) @@ -25,7 +21,7 @@ export const mutations: MutationTree = { } }, - delete(state, payload) { + filterDelete(state, payload) { if (payload in state.consolefilters) { Vue.delete(state.consolefilters, payload) } diff --git a/src/store/gui/console/types.ts b/src/store/gui/console/types.ts new file mode 100644 index 00000000..0c993c18 --- /dev/null +++ b/src/store/gui/console/types.ts @@ -0,0 +1,17 @@ +export interface GuiConsoleState { + hideWaitTemperatures: boolean + hideTlCommands: boolean + direction: 'table' | 'shell' + entryStyle: 'default' | 'compact' + height: number + consolefilters: { + [key: string]: GuiConsoleStateFilter + } +} + +export interface GuiConsoleStateFilter { + id?: string | null + bool: boolean + name: string + regex: string +} \ No newline at end of file diff --git a/src/store/gui/consolefilters/actions.ts b/src/store/gui/consolefilters/actions.ts deleted file mode 100644 index c0cf41a4..00000000 --- a/src/store/gui/consolefilters/actions.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { ActionTree } from 'vuex' -import {RootState} from '@/store/types' -import { v4 as uuidv4 } from 'uuid' -import Vue from 'vue' -import {GuiConsolefiltersState} from '@/store/gui/consolefilters/types' - -export const actions: ActionTree = { - reset({ commit }) { - commit('reset') - }, - - init() { - window.console.debug('init gui/consolefilters') - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail_consolefilters' }, { action: 'gui/consolefilters/initStore' }) - }, - - initStore({ commit }, payload) { - commit('reset') - commit('initStore', payload) - }, - - upload(_, payload) { - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail_consolefilters', key: payload.id, value: payload.value }) - }, - - store({ commit, dispatch, state }, payload) { - const id = uuidv4() - - commit('store', { id, values: payload.values }) - dispatch('upload', { - id, - value: state.consolefilters[id] - }) - }, - - update({ commit, dispatch, state }, payload) { - commit('update', payload) - dispatch('upload', { - id: payload.id, - value: state.consolefilters[payload.id] - }) - }, - - delete({ commit }, payload) { - commit('delete', payload) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail_consolefilters', key: payload }) - }, -} \ No newline at end of file diff --git a/src/store/gui/consolefilters/index.ts b/src/store/gui/consolefilters/index.ts deleted file mode 100644 index d36e4c12..00000000 --- a/src/store/gui/consolefilters/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Module } from 'vuex' -import { actions } from '@/store/gui/consolefilters/actions' -import { mutations } from '@/store/gui/consolefilters/mutations' -import { getters } from '@/store/gui/consolefilters/getters' -import {GuiConsolefiltersState} from '@/store/gui/consolefilters/types' - -export const getDefaultState = (): GuiConsolefiltersState => { - return { - consolefilters: {}, - } -} - -// initial state -const state = getDefaultState() - -// eslint-disable-next-line -export const consolefilters: Module = { - namespaced: true, - state, - getters, - actions, - mutations -} \ No newline at end of file diff --git a/src/store/gui/consolefilters/types.ts b/src/store/gui/consolefilters/types.ts deleted file mode 100644 index e588cbd4..00000000 --- a/src/store/gui/consolefilters/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface GuiConsolefiltersState { - consolefilters: { - [key: string]: GuiConsolefiltersStateFilter - } -} - -export interface GuiConsolefiltersStateFilter { - id?: string | null - bool: boolean - name: string - regex: string -} \ No newline at end of file diff --git a/src/store/gui/gcodehistory/actions.ts b/src/store/gui/gcodehistory/actions.ts index 18f62997..0c07fc44 100644 --- a/src/store/gui/gcodehistory/actions.ts +++ b/src/store/gui/gcodehistory/actions.ts @@ -9,22 +9,12 @@ export const actions: ActionTree = { commit('reset') }, - init() { - window.console.debug('init gui/gcodehistory') - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail_gcodehistory' }, { action: 'gui/gcodehistory/initStore' }) - }, - - initStore({ commit }, payload) { - commit('reset') - commit('initStore', payload) - }, - upload({ state }) { - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail_gcodehistory', key: 'history', value: state.history }) + Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'gcodehistory.entries', value: state.entries }) }, async addToHistory({ commit, dispatch, state }, payload) { - const newHistory = [...state.history] + const newHistory = [...state.entries] newHistory.push(payload) while (newHistory.length > maxGcodeHistory) newHistory.splice(0, 1) diff --git a/src/store/gui/gcodehistory/index.ts b/src/store/gui/gcodehistory/index.ts index 2ecb0fe3..e62042f4 100644 --- a/src/store/gui/gcodehistory/index.ts +++ b/src/store/gui/gcodehistory/index.ts @@ -6,7 +6,7 @@ import {GuiGcodehistoryState} from '@/store/gui/gcodehistory/types' export const getDefaultState = (): GuiGcodehistoryState => { return { - history: [], + entries: [], } } diff --git a/src/store/gui/gcodehistory/mutations.ts b/src/store/gui/gcodehistory/mutations.ts index 36ddade1..ac93efee 100644 --- a/src/store/gui/gcodehistory/mutations.ts +++ b/src/store/gui/gcodehistory/mutations.ts @@ -8,11 +8,7 @@ export const mutations: MutationTree = { Object.assign(state, getDefaultState()) }, - initStore(state, payload) { - Vue.set(state, 'history', payload.value?.history) - }, - updateHistory(state, payload) { - Vue.set(state, 'history', payload) + Vue.set(state, 'entries', payload) }, } \ No newline at end of file diff --git a/src/store/gui/gcodehistory/types.ts b/src/store/gui/gcodehistory/types.ts index 4fc127dc..50cfbd02 100644 --- a/src/store/gui/gcodehistory/types.ts +++ b/src/store/gui/gcodehistory/types.ts @@ -1,3 +1,3 @@ export interface GuiGcodehistoryState { - history: string[] + entries: string[] } \ No newline at end of file diff --git a/src/store/gui/getters.ts b/src/store/gui/getters.ts index 27cf0194..d0095347 100644 --- a/src/store/gui/getters.ts +++ b/src/store/gui/getters.ts @@ -1,25 +1,25 @@ import {GetterTree} from 'vuex' import {GuiState} from '@/store/gui/types' -import {GuiMacrogroupsStateMacrogroup} from '@/store/gui/macrogroups/types' +import {GuiMacrosStateMacrogroup} from '@/store/gui/macros/types' // eslint-disable-next-line export const getters: GetterTree = { getDatasetValue: (state) => (payload: { name: string, type: string }) => { if ( - payload.name in state.tempchart.datasetSettings && - payload.type in state.tempchart.datasetSettings[payload.name] - ) return state.tempchart.datasetSettings[payload.name][payload.type] + payload.name in state.view.tempchart.datasetSettings && + payload.type in state.view.tempchart.datasetSettings[payload.name] + ) return state.view.tempchart.datasetSettings[payload.name][payload.type] return ['temperature', 'target'].includes(payload.type) }, getDatasetAdditionalSensorValue: (state) => (payload: { name: string, sensor: string }) => { if ( - payload.name in state.tempchart.datasetSettings && - 'additionalSensors' in state.tempchart.datasetSettings[payload.name] && - payload.sensor in state.tempchart.datasetSettings[payload.name].additionalSensors - ) return state.tempchart.datasetSettings[payload.name].additionalSensors[payload.sensor] + payload.name in state.view.tempchart.datasetSettings && + 'additionalSensors' in state.view.tempchart.datasetSettings[payload.name] && + payload.sensor in state.view.tempchart.datasetSettings[payload.name].additionalSensors + ) return state.view.tempchart.datasetSettings[payload.name].additionalSensors[payload.sensor] return true }, @@ -28,19 +28,20 @@ export const getters: GetterTree = { return !state.dashboard.nonExpandPanels?.includes(name) ?? true }, - getPanels: (state, getters) => (viewport: string) => { + getPanels: (state, getters, rootState) => (viewport: string) => { + // @ts-ignore let panels = state.dashboard[viewport]?.filter((element: any) => element !== null) ?? [] - if (state.dashboard.macroManagement === 'simple') panels = panels.filter((element: any) => !element.name.startsWith('macrogroup_')) + if (rootState.gui.macros.mode === 'simple') panels = panels.filter((element: any) => !element.name.startsWith('macrogroup_')) else { panels = panels.filter((element: any) => element.name !== 'macros') - const macrogroups = getters['macrogroups/getAllMacrogroups'] + const macrogroups = getters['macros/getAllMacrogroups'] if (macrogroups.length) { panels = panels.filter((element: any) => { if (!element.name.startsWith('macrogroup_')) return true const macrogroupId = element.name.substr(11) - return (macrogroups.findIndex((macrogroup: GuiMacrogroupsStateMacrogroup) => macrogroup.id === macrogroupId) !== -1) + return (macrogroups.findIndex((macrogroup: GuiMacrosStateMacrogroup) => macrogroup.id === macrogroupId) !== -1) }) } } @@ -53,6 +54,6 @@ export const getters: GetterTree = { }, getLockedSliders: (state) => (name: string) => { - return state.dashboard.lockedSliders?.includes(name) ?? false + return state.view.lockedSliders?.includes(name) ?? false } } diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 684d63da..f0f1523f 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -6,9 +6,9 @@ import { getters } from '@/store/gui/getters' import {defaultLogoColor, defaultPrimaryColor} from '@/store/variables' // load modules -import { consolefilters } from '@/store/gui/consolefilters' +import { console } from '@/store/gui/console' import { gcodehistory } from '@/store/gui/gcodehistory' -import { macrogroups } from '@/store/gui/macrogroups' +import { macros } from '@/store/gui/macros' import { presets } from '@/store/gui/presets' import { remoteprinters } from '@/store/gui/remoteprinters' import { webcams } from '@/store/gui/webcams' @@ -18,174 +18,85 @@ export const getDefaultState = (): GuiState => { general: { printername: '', language: 'en', - displayCancelPrint: false, - displayZOffsetStandby: false, - lockSlidersOnTouchDevices: true, - lockSlidersDelay: 1.5, - confirmOnEmergencyStop: false, - confirmOnPowerDeviceChange: false, calcEstimateTime: ['file', 'filament'], - calcEtaTime: ['file', 'filament', 'slicer'], + calcEtaTime: ['file', 'filament', 'slicer'] }, - theme: { - logo: defaultLogoColor, - primary: defaultPrimaryColor, - }, - dashboard: { - boolTempchart: true, - boolBigThumbnail: true, - boolWideNavDrawer: false, - navigationStyle: 'iconsAndText', - macroManagement: 'simple', - hiddenMacros: [], - hiddenTempChart: [], - control: { - style: 'bars', - feedrateXY: 100, - stepsXY: [ 100, 10, 1 ], - feedrateZ: 25, - stepsZ: [ 25, 1, 0.1 ], - stepsAll: [0.1, 1, 10, 25, 50, 100], - stepsCircleXY: [1, 10, 50, 100], - stepsCircleZ: [0.1, 1, 10, 50], - selectedCrossStep: null, - reverseX: false, - reverseY: false, - reverseZ: false - }, + control: { + style: 'bars', + feedrateXY: 100, + stepsXY: [ 100, 10, 1 ], + feedrateZ: 25, + stepsZ: [ 25, 1, 0.1 ], + stepsAll: [0.1, 1, 10, 25, 50, 100], + stepsCircleXY: [1, 10, 50, 100], + stepsCircleZ: [0.1, 1, 10, 50], + selectedCrossStep: null, + reverseX: false, + reverseY: false, + reverseZ: false, extruder: { feedamount: 25, feedamounts: [ 50, 25, 10, 5, 1 ], feedrate: 5, feedrates: [ 15, 10, 5, 2, 1 ], }, + }, + dashboard: { + nonExpandPanels: [], mobileLayout: [ - { 'name': 'webcam', visable: false }, - { 'name': 'zoffset', visable: true }, - { 'name': 'control', visable: true }, - { 'name': 'macros', visable: true }, - { 'name': 'printsettings', visable: true }, - { 'name': 'machine-settings', visable: true }, - { 'name': 'miscellaneous', visable: true }, - { 'name': 'tools', visable: true }, - { 'name': 'miniconsole', visable: false }, + { 'name': 'webcam', visible: false }, + { 'name': 'zoffset', visible: true }, + { 'name': 'control', visible: true }, + { 'name': 'macros', visible: true }, + { 'name': 'printsettings', visible: true }, + { 'name': 'machine-settings', visible: true }, + { 'name': 'miscellaneous', visible: true }, + { 'name': 'tools', visible: true }, + { 'name': 'miniconsole', visible: false }, ], tabletLayout1: [ - { 'name': 'webcam', visable: true }, - { 'name': 'zoffset', visable: true }, - { 'name': 'control', visable: true }, - { 'name': 'macros', visable: true }, - { 'name': 'printsettings', visable: true }, - { 'name': 'machine-settings', visable: true }, - { 'name': 'miscellaneous', visable: true }, + { 'name': 'webcam', visible: true }, + { 'name': 'zoffset', visible: true }, + { 'name': 'control', visible: true }, + { 'name': 'macros', visible: true }, + { 'name': 'printsettings', visible: true }, + { 'name': 'machine-settings', visible: true }, + { 'name': 'miscellaneous', visible: true }, ], tabletLayout2: [ - { 'name': 'tools', visable: true }, - { 'name': 'miniconsole', visable: true }, + { 'name': 'tools', visible: true }, + { 'name': 'miniconsole', visible: true }, ], desktopLayout1: [ - { 'name': 'webcam', visable: true }, - { 'name': 'zoffset', visable: true }, - { 'name': 'control', visable: true }, - { 'name': 'macros', visable: true }, - { 'name': 'printsettings', visable: true }, - { 'name': 'machine-settings', visable: true }, - { 'name': 'miscellaneous', visable: true }, + { 'name': 'webcam', visible: true }, + { 'name': 'zoffset', visible: true }, + { 'name': 'control', visible: true }, + { 'name': 'macros', visible: true }, + { 'name': 'printsettings', visible: true }, + { 'name': 'machine-settings', visible: true }, + { 'name': 'miscellaneous', visible: true }, ], desktopLayout2: [ - { 'name': 'tools', visable: true }, - { 'name': 'miniconsole', visable: true }, + { 'name': 'tools', visible: true }, + { 'name': 'miniconsole', visible: true }, ], widescreenLayout1: [ - { 'name': 'zoffset', visable: true }, - { 'name': 'control', visable: true }, - { 'name': 'macros', visable: true }, - { 'name': 'miscellaneous', visable: true }, + { 'name': 'zoffset', visible: true }, + { 'name': 'control', visible: true }, + { 'name': 'macros', visible: true }, + { 'name': 'miscellaneous', visible: true }, ], widescreenLayout2: [ - { 'name': 'tools', visable: true }, - { 'name': 'printsettings', visable: true }, - { 'name': 'machine-settings', visable: true }, + { 'name': 'tools', visible: true }, + { 'name': 'printsettings', visible: true }, + { 'name': 'machine-settings', visible: true }, ], widescreenLayout3: [ - { 'name': 'webcam', visable: true }, - { 'name': 'miniconsole', visable: true }, + { 'name': 'webcam', visible: true }, + { 'name': 'miniconsole', visible: true }, ], - nonExpandPanels: [] - }, - webcamSettings: { - currentCam: { - dashboard: 'all', - page: 'all' - }, - boolNavi: false, - }, - tempchart: { - autoscale: false, - datasetSettings: { - - }, - }, - console: { - hideWaitTemperatures: true, - hideTlCommands: true, - direction: 'table', - entryStyle: 'default', - height: 300 - }, - gcodefiles: { - countPerPage: 10, - sortBy: 'modified', - sortDesc: true, - showHiddenFiles: false, - showPrintedFiles: true, - hideMetadataColums: [] - }, - timelapse: { - countPerPage: 10, - sortBy: 'modified', - sortDesc: true, - showHiddenFiles: false, - }, - jobqueue: { - countPerPage: 10, - }, - heightmap: { - probed: true, - mesh: false, - flat: false, - wireframe: true, - scale: 0.5, - scaleVisualMap: false, - }, - history: { - countPerPage: 10, - toggleChartCol3: 'filament_usage', - hidePrintStatus: [], - hideColums: [ - 'size', - 'modified', - 'end_time', - 'total_duration', - 'filament_total', - 'first_layer_extr_temp', - 'first_layer_bed_temp', - 'first_layer_height', - 'layer_height', - 'object_height', - ] - }, - settings: { - configfiles: { - countPerPage: 10, - sortBy: 'filename', - sortDesc: false, - showHiddenFiles: false, - hideBackupFiles: false - } }, editor: { - minimap: false, escToClose: true, confirmUnsavedChanges: true }, @@ -194,7 +105,7 @@ export const getDefaultState = (): GuiState => { gridColor : '#0000FF', backgroundColor : '#000000', colorMode : 2, - showAxes : 'true', + showAxes : true, minFeed : 20, maxFeed : 100, minFeedColor : '#0000FF', @@ -211,6 +122,85 @@ export const getDefaultState = (): GuiState => { voxelHeight: 1, specularLighting: false, }, + uiSettings: { + logo: defaultLogoColor, + primary: defaultPrimaryColor, + displayCancelPrint: false, + displayZOffsetStandby: false, + lockSlidersOnTouchDevices: true, + lockSlidersDelay: 1.5, + confirmOnEmergencyStop: false, + confirmOnPowerDeviceChange: false, + boolBigThumbnail: true, + boolWideNavDrawer: false, + boolHideUploadAndPrintButton: false, + boolWebcamNavi: false, + navigationStyle: 'iconsAndText', + }, + view: { + configfiles: { + countPerPage: 10, + sortBy: 'filename', + sortDesc: false, + showHiddenFiles: false, + hideBackupFiles: false + }, + gcodefiles: { + countPerPage: 10, + sortBy: 'modified', + sortDesc: true, + showHiddenFiles: false, + showPrintedFiles: true, + hideMetadataColums: [] + }, + heightmap: { + probed: true, + mesh: false, + flat: false, + wireframe: true, + scale: 0.5, + scaleVisualMap: false, + }, + history: { + countPerPage: 10, + toggleChartCol3: 'filament_usage', + hidePrintStatus: [], + hideColums: [ + 'size', + 'modified', + 'end_time', + 'total_duration', + 'filament_total', + 'first_layer_extr_temp', + 'first_layer_bed_temp', + 'first_layer_height', + 'layer_height', + 'object_height', + ] + }, + jobqueue: { + countPerPage: 10, + }, + lockedSliders: [], + tempchart: { + boolTempchart: true, + hiddenDataset: [], + autoscale: false, + datasetSettings: { }, + }, + timelapse: { + countPerPage: 10, + sortBy: 'modified', + sortDesc: true, + showHiddenFiles: false, + }, + webcam: { + currentCam: { + dashboard: 'all', + page: 'all' + }, + }, + }, } } @@ -224,9 +214,9 @@ export const gui: Module = { actions, mutations, modules: { - consolefilters, + console, gcodehistory, - macrogroups, + macros, presets, remoteprinters, webcams, diff --git a/src/store/gui/macrogroups/index.ts b/src/store/gui/macrogroups/index.ts deleted file mode 100644 index b9d12074..00000000 --- a/src/store/gui/macrogroups/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Module } from 'vuex' -import { actions } from '@/store/gui/macrogroups/actions' -import { mutations } from '@/store/gui/macrogroups/mutations' -import { getters } from '@/store/gui/macrogroups/getters' -import {GuiMacrogroupsState} from '@/store/gui/macrogroups/types' - -export const getDefaultState = (): GuiMacrogroupsState => { - return { - macrogroups: {}, - } -} - -// initial state -const state = getDefaultState() - -// eslint-disable-next-line -export const macrogroups: Module = { - namespaced: true, - state, - getters, - actions, - mutations -} \ No newline at end of file diff --git a/src/store/gui/macrogroups/actions.ts b/src/store/gui/macros/actions.ts similarity index 59% rename from src/store/gui/macrogroups/actions.ts rename to src/store/gui/macros/actions.ts index b4895c66..96038443 100644 --- a/src/store/gui/macrogroups/actions.ts +++ b/src/store/gui/macros/actions.ts @@ -2,64 +2,62 @@ import { ActionTree } from 'vuex' import {RootState} from '@/store/types' import { v4 as uuidv4 } from 'uuid' import Vue from 'vue' -import {GuiMacrogroupsState} from '@/store/gui/macrogroups/types' +import {GuiMacrosState} from '@/store/gui/macros/types' -export const actions: ActionTree = { +export const actions: ActionTree = { reset({ commit }) { commit('reset') }, - init() { - window.console.debug('init gui/macrogroups') - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail_macrogroups' }, { action: 'gui/macrogroups/initStore' }) + saveSetting({ dispatch }, payload) { + dispatch('gui/saveSetting', { + name: 'macros.'+payload.name, + value: payload.value + }, { root: true }) }, - initStore({ commit }, payload) { - commit('reset') - commit('initStore', payload) + groupUpload({ state }, id) { + Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'macros.macrogroups.'+id, value: state.macrogroups[id] }) }, - upload({ state }, id) { - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail_macrogroups', key: id, value: state.macrogroups[id] }) - }, - - async store({ commit, dispatch, state }, payload) { + async groupStore({ commit, dispatch, state }, payload) { const id = uuidv4() - await commit('store', { id, values: payload.values }) - await dispatch('upload', id) + await commit('groupStore', { id, values: payload.values }) + await dispatch('groupUpload', id) return id }, - update({ commit, dispatch, state }, payload) { - commit('update', payload) - dispatch('upload', payload.id) + groupUpdate({ commit, dispatch, state }, payload) { + commit('groupUpdate', payload) + dispatch('groupUpload', payload.id) }, addMacroToMacrogroup({ commit, dispatch }, payload) { commit('addMacroToMacrogroup', payload) - dispatch('upload', payload.id) + dispatch('groupUpload', payload.id) }, updateMacroFromMacrogroup({ commit, dispatch }, payload) { commit('updateMacroFromMacrogroup', payload) - dispatch('upload', payload.id) + dispatch('groupUpload', payload.id) }, removeMacroFromMacrogroup({ commit, dispatch }, payload) { commit('removeMacroFromMacrogroup', payload) - dispatch('upload', payload.id) + dispatch('groupUpload', payload.id) }, - delete({ commit, dispatch, rootState }, id) { - commit('delete', id) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail_macrogroups', key: id }) + groupDelete({ commit, dispatch, rootState }, id) { + commit('groupDelete', id) + Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'macros.macrogroups.'+id }) const layouts = ['mobileLayout', 'tabletLayout1', 'tabletLayout2', 'desktopLayout1', 'desktopLayout2', 'widescreenLayout1', 'widescreenLayout2', 'widescreenLayout3'] layouts.forEach((layoutname: string) => { + // @ts-ignore const layoutArray = [...rootState.gui?.dashboard[layoutname]] const index = layoutArray.findIndex((layoutPos: any) => layoutPos.name === 'macrogroup_'+id) @@ -67,6 +65,7 @@ export const actions: ActionTree = { commit('gui/deleteFromDashboardLayout', { layoutname, index }, { root: true }) dispatch('gui/updateSettings', { keyName: 'dashboard.'+layoutname, + // @ts-ignore newVal: rootState.gui?.dashboard[layoutname] }, { root: true }) } diff --git a/src/store/gui/macrogroups/getters.ts b/src/store/gui/macros/getters.ts similarity index 66% rename from src/store/gui/macrogroups/getters.ts rename to src/store/gui/macros/getters.ts index db0552ba..f64e26ad 100644 --- a/src/store/gui/macrogroups/getters.ts +++ b/src/store/gui/macros/getters.ts @@ -1,12 +1,12 @@ import { GetterTree } from 'vuex' -import {GuiMacrogroupsState, GuiMacrogroupsStateMacrogroup} from '@/store/gui/macrogroups/types' +import {GuiMacrosState, GuiMacrosStateMacrogroup} from '@/store/gui/macros/types' import {caseInsensitiveSort} from '@/plugins/helpers' // eslint-disable-next-line -export const getters: GetterTree = { +export const getters: GetterTree = { getAllMacrogroups: (state) => { - const macrogroups: GuiMacrogroupsStateMacrogroup[] = [] + const macrogroups: GuiMacrosStateMacrogroup[] = [] Object.keys(state.macrogroups).forEach((id: string) => { macrogroups.push({...state.macrogroups[id], id}) diff --git a/src/store/gui/macros/index.ts b/src/store/gui/macros/index.ts new file mode 100644 index 00000000..af12a4b8 --- /dev/null +++ b/src/store/gui/macros/index.ts @@ -0,0 +1,25 @@ +import { Module } from 'vuex' +import { actions } from '@/store/gui/macros/actions' +import { mutations } from '@/store/gui/macros/mutations' +import { getters } from '@/store/gui/macros/getters' +import {GuiMacrosState} from '@/store/gui/macros/types' + +export const getDefaultState = (): GuiMacrosState => { + return { + mode: 'simple', + hiddenMacros: [], + macrogroups: {}, + } +} + +// initial state +const state = getDefaultState() + +// eslint-disable-next-line +export const macros: Module = { + namespaced: true, + state, + getters, + actions, + mutations +} \ No newline at end of file diff --git a/src/store/gui/macrogroups/mutations.ts b/src/store/gui/macros/mutations.ts similarity index 66% rename from src/store/gui/macrogroups/mutations.ts rename to src/store/gui/macros/mutations.ts index 01d6f96c..8f7ed282 100644 --- a/src/store/gui/macrogroups/mutations.ts +++ b/src/store/gui/macros/mutations.ts @@ -1,22 +1,18 @@ -import { getDefaultState } from './index' +import {getDefaultState} from './index' import {MutationTree} from 'vuex' import Vue from 'vue' -import {GuiMacrogroupsState, GuiMacrogroupsStateMacrogroupMacro} from '@/store/gui/macrogroups/types' +import {GuiMacrosState, GuiMacrosStateMacrogroupMacro} from '@/store/gui/macros/types' -export const mutations: MutationTree = { +export const mutations: MutationTree = { reset(state) { Object.assign(state, getDefaultState()) }, - initStore(state, payload) { - Vue.set(state, 'macrogroups', payload.value) - }, - - store(state, payload) { + groupStore(state, payload) { Vue.set(state.macrogroups, payload.id, payload.values) }, - update(state, payload) { + groupUpdate(state, payload) { if (payload.id in state.macrogroups) { const preset = {...state.macrogroups[payload.id]} Object.assign(preset, payload.values) @@ -28,7 +24,7 @@ export const mutations: MutationTree = { addMacroToMacrogroup(state, payload) { const macros = [...state.macrogroups[payload.id]?.macros ?? []] - const newMacro: GuiMacrogroupsStateMacrogroupMacro = { + const newMacro: GuiMacrosStateMacrogroupMacro = { pos: 1, name: payload.macro, color: 'group', @@ -37,7 +33,7 @@ export const mutations: MutationTree = { showInPause: true } - if (macros.length) newMacro.pos = Math.max(...macros.map((m: GuiMacrogroupsStateMacrogroupMacro) => m.pos)) + 1 + if (macros.length) newMacro.pos = Math.max(...macros.map((m: GuiMacrosStateMacrogroupMacro) => m.pos)) + 1 macros.push(newMacro) Vue.set(state.macrogroups[payload.id], 'macros', macros) @@ -45,7 +41,7 @@ export const mutations: MutationTree = { updateMacroFromMacrogroup(state, payload) { const macros = [...state.macrogroups[payload.id]?.macros ?? []] - const updateMacroIndex = macros.findIndex((m: GuiMacrogroupsStateMacrogroupMacro) => m.name === payload.macro) + const updateMacroIndex = macros.findIndex((m: GuiMacrosStateMacrogroupMacro) => m.name === payload.macro) if (updateMacroIndex !== -1) { const macro = macros[updateMacroIndex] // @ts-ignore @@ -56,12 +52,12 @@ export const mutations: MutationTree = { removeMacroFromMacrogroup(state, payload) { const macros = [...state.macrogroups[payload.id]?.macros ?? []] - const deletedMacroIndex = macros.findIndex((m: GuiMacrogroupsStateMacrogroupMacro) => m.name === payload.macro) + const deletedMacroIndex = macros.findIndex((m: GuiMacrosStateMacrogroupMacro) => m.name === payload.macro) if (deletedMacroIndex !== -1) { const oldPos = macros[deletedMacroIndex].pos macros.splice(deletedMacroIndex, 1) - macros.filter((macro: GuiMacrogroupsStateMacrogroupMacro) => macro.pos > oldPos).forEach((macro: GuiMacrogroupsStateMacrogroupMacro) => { + macros.filter((macro: GuiMacrosStateMacrogroupMacro) => macro.pos > oldPos).forEach((macro: GuiMacrosStateMacrogroupMacro) => { macro.pos = macro.pos - 1 }) } @@ -69,7 +65,7 @@ export const mutations: MutationTree = { Vue.set(state.macrogroups[payload.id], 'macros', macros) }, - delete(state, payload) { + groupDelete(state, payload) { if (payload in state.macrogroups) { Vue.delete(state.macrogroups, payload) } diff --git a/src/store/gui/macrogroups/types.ts b/src/store/gui/macros/types.ts similarity index 61% rename from src/store/gui/macrogroups/types.ts rename to src/store/gui/macros/types.ts index 01df1f83..e7e18e7a 100644 --- a/src/store/gui/macrogroups/types.ts +++ b/src/store/gui/macros/types.ts @@ -1,10 +1,12 @@ -export interface GuiMacrogroupsState { +export interface GuiMacrosState { + mode: 'simple' | 'expert' + hiddenMacros: string[] macrogroups: { - [key: string]: GuiMacrogroupsStateMacrogroup + [key: string]: GuiMacrosStateMacrogroup } } -export interface GuiMacrogroupsStateMacrogroup { +export interface GuiMacrosStateMacrogroup { id: string | null name: string color: 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'custom' @@ -12,10 +14,10 @@ export interface GuiMacrogroupsStateMacrogroup { showInStandby: boolean showInPrinting: boolean showInPause: boolean - macros?: GuiMacrogroupsStateMacrogroupMacro[] + macros?: GuiMacrosStateMacrogroupMacro[] } -export interface GuiMacrogroupsStateMacrogroupMacro { +export interface GuiMacrosStateMacrogroupMacro { pos: number name: string color: 'group' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' diff --git a/src/store/gui/mutations.ts b/src/store/gui/mutations.ts index 28b03595..77f6148c 100644 --- a/src/store/gui/mutations.ts +++ b/src/store/gui/mutations.ts @@ -43,38 +43,38 @@ export const mutations: MutationTree = { }, setHeaterChartVisibility(state, payload) { - const index = state.dashboard.hiddenTempChart.indexOf(payload.name.toUpperCase()) + const index = state.view.tempchart.hiddenDataset.indexOf(payload.name.toUpperCase()) - if (payload.hidden && index === -1) state.dashboard.hiddenTempChart.push(payload.name.toUpperCase()) - else if (payload.hidden !== true && index > -1) state.dashboard.hiddenTempChart.splice(index, 1) + if (payload.hidden && index === -1) state.view.tempchart.hiddenDataset.push(payload.name.toUpperCase()) + else if (payload.hidden !== true && index > -1) state.view.tempchart.hiddenDataset.splice(index, 1) }, setGcodefilesMetadata(state, data) { - if (data.value && state.gcodefiles.hideMetadataColums.includes(data.name)) { - state.gcodefiles.hideMetadataColums.splice(state.gcodefiles.hideMetadataColums.indexOf(data.name), 1) - } else if (!data.value && !state.gcodefiles.hideMetadataColums.includes(data.name)) { - state.gcodefiles.hideMetadataColums.push(data.name) + if (data.value && state.view.gcodefiles.hideMetadataColums.includes(data.name)) { + state.view.gcodefiles.hideMetadataColums.splice(state.view.gcodefiles.hideMetadataColums.indexOf(data.name), 1) + } else if (!data.value && !state.view.gcodefiles.hideMetadataColums.includes(data.name)) { + state.view.gcodefiles.hideMetadataColums.push(data.name) } }, setGcodefilesShowHiddenFiles(state, value) { - Vue.set(state.gcodefiles, 'showHiddenFiles', value) + Vue.set(state.view.gcodefiles, 'showHiddenFiles', value) }, setCurrentWebcam(state, payload) { - Vue.set(state.webcamSettings.currentCam, payload.viewport, payload.value) + Vue.set(state.view.webcam.currentCam, payload.viewport, payload.value) }, setHistoryColumns(state, data) { - if (data.value && state.history.hideColums.includes(data.name)) { - state.history.hideColums.splice(state.history.hideColums.indexOf(data.name), 1) - } else if (!data.value && !state.history.hideColums.includes(data.name)) { - state.history.hideColums.push(data.name) + if (data.value && state.view.history.hideColums.includes(data.name)) { + state.view.history.hideColums.splice(state.view.history.hideColums.indexOf(data.name), 1) + } else if (!data.value && !state.view.history.hideColums.includes(data.name)) { + state.view.history.hideColums.push(data.name) } }, setHistoryHidePrintStatus(state, payload) { - Vue.set(state.history, 'hidePrintStatus', payload) + Vue.set(state.view.history, 'hidePrintStatus', payload) }, addClosePanel(state, payload) { @@ -98,13 +98,14 @@ export const mutations: MutationTree = { }, deleteFromDashboardLayout(state, payload) { + // @ts-ignore const layoutArray = [...state.dashboard[payload.layoutname]] layoutArray.splice(payload.index, 1) Vue.set(state.dashboard, payload.layoutname, layoutArray) }, addToLockedSliders(state, payload){ - const lockedSliders = [...state.dashboard.lockedSliders] + const lockedSliders = [...state.view.lockedSliders] if (!lockedSliders.includes(payload.name)) { lockedSliders.push(payload.name) @@ -113,7 +114,7 @@ export const mutations: MutationTree = { }, removeFromLockedSliders(state, payload){ - const lockedSliders = [...state.dashboard.lockedSliders] + const lockedSliders = [...state.view.lockedSliders] const index = lockedSliders.indexOf(payload.name) if (index > -1) { lockedSliders.splice(index, 1) @@ -125,21 +126,4 @@ export const mutations: MutationTree = { toggleHideUploadAndPrintBtn(state, payload) { Vue.set(state.dashboard, 'boolHideUploadAndPrintButton', payload) }, - - setResetDatabases(state, payload) { - const array: string[] = [] - Object.keys(payload).forEach((element) => { - if (payload[element] === true) array.push(element) - }) - - Vue.set(state, 'resetDatabases', array) - }, - - removeResetDatabase(state, payload) { - const array = [...state.resetDatabases] - const index = array.findIndex((element) => element === payload) - if (index !== -1) array.splice(index, 1) - - Vue.set(state, 'resetDatabases', array) - } } diff --git a/src/store/gui/presets/actions.ts b/src/store/gui/presets/actions.ts index 57fd754d..2111b73f 100644 --- a/src/store/gui/presets/actions.ts +++ b/src/store/gui/presets/actions.ts @@ -9,18 +9,15 @@ export const actions: ActionTree = { commit('reset') }, - init() { - window.console.debug('init gui/presets') - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail_presets' }, { action: 'gui/presets/initStore' }) - }, - - initStore({ commit }, payload) { - commit('reset') - commit('initStore', payload) + saveSetting({ dispatch }, payload) { + dispatch('gui/saveSetting', { + name: 'presets.'+payload.name, + value: payload.value + }, { root: true }) }, upload(_, payload) { - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail_presets', key: payload.id, value: payload.value }) + Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'presets.presets.'+payload.id, value: payload.value }) }, store({ commit, dispatch, state }, payload) { @@ -41,16 +38,8 @@ export const actions: ActionTree = { }) }, - updateCooldownGcode({ commit, dispatch }, payload) { - commit('updateCooldownGcode', payload) - dispatch('upload', { - id: 'cooldownGcode', - value: payload - }) - }, - delete({ commit }, payload) { commit('delete', payload) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail_presets', key: payload }) + Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'presets.presets.'+payload }) }, } \ No newline at end of file diff --git a/src/store/gui/remoteprinters/actions.ts b/src/store/gui/remoteprinters/actions.ts index 6ef3c177..4b518f3b 100644 --- a/src/store/gui/remoteprinters/actions.ts +++ b/src/store/gui/remoteprinters/actions.ts @@ -6,21 +6,14 @@ import {GuiRemoteprintersState} from '@/store/gui/remoteprinters/types' export const actions: ActionTree = { reset({ commit, dispatch, state }) { - Object.keys(state.remoteprinters).forEach((printerId) => { + Object.keys(state.printers).forEach((printerId) => { dispatch('farm/unregisterPrinter', printerId, { root: true }) }) commit('reset') }, - init() { - window.console.debug('init gui/remoteprinters') - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail_remoteprinters' }, { action: 'gui/remoteprinters/initStore' }) - }, - initFromLocalstorage({ dispatch }) { - window.console.debug('init gui/remoteprinters from localStorage') - const value = JSON.parse(localStorage.getItem('printers') ?? '{}') if (Array.isArray(value)) { const printers: any = {} @@ -30,15 +23,14 @@ export const actions: ActionTree = { printers[id] = printer }) - dispatch('initStore', { value: printers }) - } else dispatch('initStore', { value }) + dispatch('initStore', printers) + } }, async initStore({ commit, dispatch, state }, payload) { dispatch('reset') - - Object.keys(payload.value).forEach((printerId: string) => { - const printer = payload.value[printerId] + Object.keys(payload).forEach((printerId: string) => { + const printer = payload[printerId] commit('store', { id: printerId, values: printer }) dispatch('farm/registerPrinter', { id: printerId, @@ -53,23 +45,23 @@ export const actions: ActionTree = { if (rootState.socket?.remoteMode) { const printers: any[] = [] - Object.keys(state.remoteprinters).forEach((id: string) => { + Object.keys(state.printers).forEach((id: string) => { printers.push({ - hostname: state.remoteprinters[id].hostname, - port: state.remoteprinters[id].port, - settings: state.remoteprinters[id].settings, + hostname: state.printers[id].hostname, + port: state.printers[id].port, + settings: state.printers[id].settings, }) }) localStorage.setItem('printers', JSON.stringify(printers)) - } else if (id in state.remoteprinters) { + } else if (id in state.printers) { const value = { - hostname: state.remoteprinters[id].hostname, - port: state.remoteprinters[id].port, - settings: state.remoteprinters[id].settings ?? {}, + hostname: state.printers[id].hostname, + port: state.printers[id].port, + settings: state.printers[id].settings ?? {}, } - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail_remoteprinters', key: id, value }) + Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'remoteprinters.printers.'+id, value }) } }, @@ -107,6 +99,6 @@ export const actions: ActionTree = { commit('delete', id) dispatch('farm/unregisterPrinter', id, { root: true }) - Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail_remoteprinters', key: id }) + Vue.$socket.emit('server.database.delete_item', { namespace: 'mainsail', key: 'remoteprinters.printers'+id }) }, } \ No newline at end of file diff --git a/src/store/gui/remoteprinters/getters.ts b/src/store/gui/remoteprinters/getters.ts index 1844e250..e64a0039 100644 --- a/src/store/gui/remoteprinters/getters.ts +++ b/src/store/gui/remoteprinters/getters.ts @@ -8,14 +8,14 @@ import {caseInsensitiveSort} from '@/plugins/helpers' // eslint-disable-next-line export const getters: GetterTree = { getRemoteprinters: (state, getters, rootState, rootGetters) => { - const remoteprinters: GuiRemoteprintersStatePrinter[] = [] + const printers: GuiRemoteprintersStatePrinter[] = [] - Object.keys(state.remoteprinters).forEach((id: string) => { + Object.keys(state.printers).forEach((id: string) => { const socket = {...rootGetters['farm/getPrinterSocketState'](id)} - remoteprinters.push({...state.remoteprinters[id], id, socket}) + printers.push({...state.printers[id], id, socket}) }) - return caseInsensitiveSort(remoteprinters, 'hostname') + return caseInsensitiveSort(printers, 'hostname') }, } \ No newline at end of file diff --git a/src/store/gui/remoteprinters/index.ts b/src/store/gui/remoteprinters/index.ts index a4741353..e7138c47 100644 --- a/src/store/gui/remoteprinters/index.ts +++ b/src/store/gui/remoteprinters/index.ts @@ -6,7 +6,7 @@ import {GuiRemoteprintersState} from '@/store/gui/remoteprinters/types' export const getDefaultState = (): GuiRemoteprintersState => { return { - remoteprinters: {}, + printers: {}, } } diff --git a/src/store/gui/remoteprinters/mutations.ts b/src/store/gui/remoteprinters/mutations.ts index bcf0aa99..7eaf9b67 100644 --- a/src/store/gui/remoteprinters/mutations.ts +++ b/src/store/gui/remoteprinters/mutations.ts @@ -9,21 +9,21 @@ export const mutations: MutationTree = { }, store(state, payload) { - Vue.set(state.remoteprinters, payload.id, payload.values) + Vue.set(state.printers, payload.id, payload.values) }, update(state, payload) { - if (payload.id in state.remoteprinters) { - const preset = {...state.remoteprinters[payload.id]} + if (payload.id in state.printers) { + const preset = {...state.printers[payload.id]} Object.assign(preset, payload.values) - Vue.set(state.remoteprinters, payload.id, preset) + Vue.set(state.printers, payload.id, preset) } }, delete(state, payload) { - if (payload in state.remoteprinters) { - Vue.delete(state.remoteprinters, payload) + if (payload in state.printers) { + Vue.delete(state.printers, payload) } }, } \ No newline at end of file diff --git a/src/store/gui/remoteprinters/types.ts b/src/store/gui/remoteprinters/types.ts index 0a386be0..4ebbaabd 100644 --- a/src/store/gui/remoteprinters/types.ts +++ b/src/store/gui/remoteprinters/types.ts @@ -1,7 +1,7 @@ import {FarmPrinterStateSocket} from '@/store/farm/printer/types' export interface GuiRemoteprintersState { - remoteprinters: { + printers: { [key: string]: GuiRemoteprintersStatePrinter } } diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index 5e519806..a55ff004 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -1,10 +1,147 @@ +import {GuiMacrosState} from '@/store/gui/macros/types' +import {GuiConsoleState} from '@/store/gui/console/types' +import {GuiPresetsState} from '@/store/gui/presets/types' +import {GuiRemoteprintersState} from '@/store/gui/remoteprinters/types' + export interface GuiState { - webcamSettings: { - currentCam: { - dashboard: string - page: string - } - boolNavi: boolean + general: { + printername: string + language: string + calcEstimateTime: string[] // file, filament are possible values + calcEtaTime: string[] // file, filament, slicer are possible values } - [key: string]: any + console?: GuiConsoleState + control: { + style: 'bars' | 'circle' | 'cross' + feedrateXY: number + stepsXY: number[] + feedrateZ: number + stepsZ: number[] + stepsAll: number[] + stepsCircleXY: number[] + stepsCircleZ: number[] + selectedCrossStep: null | number + reverseX: boolean + reverseY: boolean + reverseZ: boolean + extruder: { + feedamount: number + feedamounts: number[] + feedrate: number + feedrates: number[] + } + } + dashboard: { + nonExpandPanels: string[] + mobileLayout: GuiStateLayoutoption[] + tabletLayout1: GuiStateLayoutoption[] + tabletLayout2: GuiStateLayoutoption[] + desktopLayout1: GuiStateLayoutoption[] + desktopLayout2: GuiStateLayoutoption[] + widescreenLayout1: GuiStateLayoutoption[] + widescreenLayout2: GuiStateLayoutoption[] + widescreenLayout3: GuiStateLayoutoption[] + } + editor: { + escToClose: boolean + confirmUnsavedChanges: boolean + } + gcodeViewer: { + extruderColors : string[] + gridColor : string + backgroundColor : string + colorMode : number + showAxes : boolean + minFeed : number + maxFeed : number + minFeedColor : string + maxFeedColor : string + progressColor : string + showCursor: boolean + showTravelMoves: boolean + showObjectSelection: boolean + hdRendering: boolean + forceLineRendering: boolean + transparency: boolean + voxelMode: boolean + voxelWidth: number + voxelHeight: number + specularLighting: boolean + } + macros?: GuiMacrosState + presets?: GuiPresetsState + remoteprinters?: GuiRemoteprintersState + uiSettings: { + logo: string + primary: string + displayCancelPrint: boolean + displayZOffsetStandby: boolean + lockSlidersOnTouchDevices: boolean + lockSlidersDelay: number + confirmOnEmergencyStop: boolean + confirmOnPowerDeviceChange: boolean + boolBigThumbnail: boolean + boolWideNavDrawer: boolean + boolHideUploadAndPrintButton: boolean + boolWebcamNavi: boolean + navigationStyle: 'iconsAndText' | 'iconsOnly' + } + view: { + configfiles: { + countPerPage: number + sortBy: string + sortDesc: boolean + showHiddenFiles: boolean + hideBackupFiles: boolean + } + gcodefiles: { + countPerPage: number + sortBy: string + sortDesc: boolean + showHiddenFiles: boolean + showPrintedFiles: boolean + hideMetadataColums: string[] + } + heightmap: { + probed: boolean + mesh: boolean + flat: boolean + wireframe: boolean + scale: number + scaleVisualMap: boolean + } + history: { + countPerPage: number + toggleChartCol3: string + hidePrintStatus: string[] + hideColums: string[] + } + jobqueue: { + countPerPage: number + } + lockedSliders: string[] + tempchart: { + boolTempchart: boolean + hiddenDataset: string[] + autoscale: boolean + datasetSettings: any + } + timelapse: { + countPerPage: number + sortBy: string + sortDesc: boolean + showHiddenFiles: boolean + } + webcam: { + currentCam: { + dashboard: string + page: string + } + } + } +} + +export interface GuiStateLayoutoption { + name: string + visible: boolean } \ No newline at end of file diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index ec1fb536..57c3cb7a 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -49,7 +49,7 @@ export const getters: GetterTree = { const array: PrinterStateMacro[] = [] const hiddenMacros: string[] = [] - rootState.gui?.dashboard.hiddenMacros.forEach((item: string, index: number) => { + rootState.gui?.macros?.hiddenMacros.forEach((item: string, index: number) => { hiddenMacros[index] = item.toLowerCase() }) @@ -365,7 +365,7 @@ export const getters: GetterTree = { getAllMacros: state => { const array: PrinterStateMacro[] = [] - Object.keys(state.configfile.config).forEach(prop => { + Object.keys(state.configfile?.config ?? {}).forEach(prop => { if (prop.startsWith('gcode_macro') && !prop.startsWith('gcode_macro _') && !Object.hasOwnProperty.call(state.configfile.config[prop], 'rename_existing')) { diff --git a/src/store/server/actions.ts b/src/store/server/actions.ts index 1dfa2a1e..edce7928 100644 --- a/src/store/server/actions.ts +++ b/src/store/server/actions.ts @@ -24,12 +24,8 @@ export const actions: ActionTree = { checkDatabases({ dispatch, commit, rootState }, payload) { if (payload.namespaces?.includes('mainsail')) dispatch('gui/init', null, { root: true }) + else dispatch('gui/initDb', null, { root: true }) if (payload.namespaces?.includes('webcams')) dispatch('gui/webcams/init', null, { root: true }) - if (payload.namespaces?.includes('mainsail_presets')) dispatch('gui/presets/init', null, { root: true }) - if (payload.namespaces?.includes('mainsail_consolefilters')) dispatch('gui/consolefilters/init', null, { root: true }) - if (payload.namespaces?.includes('mainsail_gcodehistory')) dispatch('gui/gcodehistory/init', null, { root: true }) - if (payload.namespaces?.includes('mainsail_macrogroups')) dispatch('gui/macrogroups/init', null, { root: true }) - if (!rootState.socket?.remoteMode && payload.namespaces?.includes('mainsail_remoteprinters')) dispatch('gui/remoteprinters/init', null, { root: true }) commit('saveDbNamespaces', payload.namespaces) @@ -84,7 +80,7 @@ export const actions: ActionTree = { commit('clearGcodeStore') let events: ServerStateEvent[] = payload.gcode_store - const filters = rootGetters['gui/consolefilters/getConsolefilterRules'] + const filters = rootGetters['gui/console/getConsolefilterRules'] filters.forEach((filter: string) => { try { const regex = new RegExp(filter) @@ -113,7 +109,7 @@ export const actions: ActionTree = { let formatMessage = formatConsoleMessage(message) - const filters = rootGetters['gui/consolefilters/getConsolefilterRules'] + const filters = rootGetters['gui/console/getConsolefilterRules'] let boolImport = true filters.every((filter: string) => { try { diff --git a/src/store/server/history/getters.ts b/src/store/server/history/getters.ts index d25f9042..865a035a 100644 --- a/src/store/server/history/getters.ts +++ b/src/store/server/history/getters.ts @@ -111,7 +111,7 @@ export const getters: GetterTree = { name: current.status, value: 1, itemStyle: itemStyle, - showInTable: !rootState.gui?.history.hidePrintStatus.includes(current.status), + showInTable: !rootState.gui?.view.history.hidePrintStatus.includes(current.status), label: { color: '#fff' } @@ -216,7 +216,7 @@ export const getters: GetterTree = { }, getFilterdJobList: (state, getters, rootState) => { - const hideStatus = rootState.gui.history.hidePrintStatus + const hideStatus = rootState.gui.view.history.hidePrintStatus return state.jobs.filter((job: ServerHistoryStateJob) => { return !hideStatus.includes(job.status)
{{ $t('Settings.GeneralTab.BackupDialog') }}
{{ $t('Settings.GeneralTab.RestoreDialog') }}