From c141e0d56b8b7c568edec5552fd78421f60a69e9 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 20 Nov 2024 21:42:23 +0100 Subject: [PATCH 1/3] feat(Dashboard): add option to change length of files list in the StatusPanel Signed-off-by: Stefan Dej --- src/components/panels/Status/Gcodefiles.vue | 6 ++++- src/components/panels/StatusPanel.vue | 11 ++++++++-- .../settings/SettingsUiSettingsTab.vue | 22 +++++++++++++++++++ src/locales/en.json | 3 +++ src/store/gui/index.ts | 1 + src/store/gui/types.ts | 1 + 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/components/panels/Status/Gcodefiles.vue b/src/components/panels/Status/Gcodefiles.vue index f8d5488c0..51aa1b80e 100644 --- a/src/components/panels/Status/Gcodefiles.vue +++ b/src/components/panels/Status/Gcodefiles.vue @@ -38,6 +38,10 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi filesGcodeCard: Vue } + get filesLimit() { + return this.$store.state.gui.uiSettings.dashboardFilesLimit ?? 5 + } + get gcodeFiles() { let gcodes = this.$store.getters['files/getAllGcodes'] ?? [] gcodes = gcodes @@ -45,7 +49,7 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi .sort((a: FileStateGcodefile, b: FileStateGcodefile) => { return b.modified.getTime() - a.modified.getTime() }) - .slice(0, 5) + .slice(0, this.filesLimit) const requestItems = gcodes.filter( (file: FileStateGcodefile) => !file.metadataRequested && !file.metadataPulled diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index d0a3833bb..6d2ec516b 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -90,7 +90,7 @@ {{ $t('Panels.StatusPanel.Status') }} - {{ $t('Panels.StatusPanel.Files') }} + {{ $t('Panels.StatusPanel.Files') }} {{ $t('Panels.StatusPanel.Jobqueue') }} @@ -102,7 +102,7 @@ - + @@ -362,8 +362,15 @@ export default class StatusPanel extends Mixins(BaseMixin) { return this.layer_count !== null && (this.existsSetPauseAtLayer || this.existsSetPauseNextLayer) } + get displayFilesTab() { + const count = this.$store.state.gui.uiSettings.dashboardFilesLimit ?? 5 + + return count > 0 + } + mounted() { if (this.current_filename !== '') this.activeTab = 'status' + if (!this.displayFilesTab) this.activeTab = 'jobqueue' } @Watch('current_filename') diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 14bb0f33e..2612e6fa6 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -282,6 +282,20 @@ :dynamic-slot-width="true"> + + + + @@ -615,6 +629,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin, ThemeMixin) this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.hideUpdateWarnings', value: newVal }) } + get dashboardFilesLimit() { + return this.$store.state.gui.uiSettings.dashboardFilesLimit ?? 5 + } + + set dashboardFilesLimit(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.dashboardFilesLimit', value: newVal }) + } + clearColorObject(color: any): string { if (typeof color === 'object' && 'hex' in color) color = color.hex if (color.length > 7) color = color.substr(0, 7) diff --git a/src/locales/en.json b/src/locales/en.json index 36b87a326..26364c3f4 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1229,6 +1229,9 @@ "ConfirmOnEmergencyStopDescription": "Show a confirmation dialog on Emergency Stop", "ConfirmOnPowerDeviceChange": "Require confirm on Device Power changes", "ConfirmOnPowerDeviceChangeDescription": "Show a confirmation dialog on Device Power changes", + "DashboardFilesLimit": "Dashboard Files Limit", + "DashboardFilesLimitDescription": "Select the maximum number of files to display on the dashboard in the Status Panel. (0 will hide the files tab)", + "DashboardFilesLimitLabel": "{count} files", "DefaultNavigationState": "Navigation default state", "DefaultNavigationStateAlwaysClosed": "always closed", "DefaultNavigationStateAlwaysOpen": "always open", diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index b8aaa2903..d02de88b5 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -183,6 +183,7 @@ export const getDefaultState = (): GuiState => { tempchartHeight: 250, hideUpdateWarnings: false, printstatusThumbnailZoom: true, + dashboardFilesLimit: 5, }, view: { blockFileUpload: false, diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index fb3589081..364c58725 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -125,6 +125,7 @@ export interface GuiState { tempchartHeight: number hideUpdateWarnings: boolean printstatusThumbnailZoom: boolean + dashboardFilesLimit: number } view: { blockFileUpload: boolean From 78e61b7c6674354d0c5754e45188810e7e00328f Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 20 Nov 2024 22:55:39 +0100 Subject: [PATCH 2/3] feat(Dashboard): add option to filter files in StatusPanel Signed-off-by: Stefan Dej --- src/components/panels/Status/Gcodefiles.vue | 21 ++++++++++- .../settings/SettingsUiSettingsTab.vue | 37 +++++++++++++++++++ src/locales/en.json | 5 +++ src/store/gui/index.ts | 1 + src/store/gui/types.ts | 3 ++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/components/panels/Status/Gcodefiles.vue b/src/components/panels/Status/Gcodefiles.vue index 51aa1b80e..493a2d6f7 100644 --- a/src/components/panels/Status/Gcodefiles.vue +++ b/src/components/panels/Status/Gcodefiles.vue @@ -42,10 +42,29 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi return this.$store.state.gui.uiSettings.dashboardFilesLimit ?? 5 } + get filesFilter() { + return this.$store.state.gui.uiSettings.dashboardFilesFilter ?? [] + } + get gcodeFiles() { let gcodes = this.$store.getters['files/getAllGcodes'] ?? [] + + if (this.filesFilter.length > 0 && this.filesFilter.length < 3) { + gcodes = gcodes.filter((file: FileStateGcodefile) => { + if (this.filesFilter.includes('new') && file.last_status === null) return true + if (this.filesFilter.includes('completed') && file.last_status === 'completed') return true + if ( + this.filesFilter.includes('failed') && + file.last_status !== null && + file.last_status !== 'completed' + ) + return true + + return false + }) + } + gcodes = gcodes - .slice() .sort((a: FileStateGcodefile, b: FileStateGcodefile) => { return b.modified.getTime() - a.modified.getTime() }) diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 2612e6fa6..0d420a506 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -296,6 +296,18 @@ $t('Settings.UiSettingsTab.DashboardFilesLimitLabel', { count: dashboardFilesLimit }) " /> + + + + @@ -637,6 +649,31 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin, ThemeMixin) this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.dashboardFilesLimit', value: newVal }) } + get dashboardFilesFilter() { + return this.$store.state.gui.uiSettings.dashboardFilesFilter ?? [] + } + + set dashboardFilesFilter(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.dashboardFilesFilter', value: newVal }) + } + + get dashboardFilesFilters() { + return [ + { + text: this.$t('Settings.UiSettingsTab.DashboardFilesFilterNew'), + value: 'new', + }, + { + text: this.$t('Settings.UiSettingsTab.DashboardFilesFilterFailed'), + value: 'failed', + }, + { + text: this.$t('Settings.UiSettingsTab.DashboardFilesFilterCompleted'), + value: 'completed', + }, + ] + } + clearColorObject(color: any): string { if (typeof color === 'object' && 'hex' in color) color = color.hex if (color.length > 7) color = color.substr(0, 7) diff --git a/src/locales/en.json b/src/locales/en.json index 26364c3f4..77dd1754b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1229,6 +1229,11 @@ "ConfirmOnEmergencyStopDescription": "Show a confirmation dialog on Emergency Stop", "ConfirmOnPowerDeviceChange": "Require confirm on Device Power changes", "ConfirmOnPowerDeviceChangeDescription": "Show a confirmation dialog on Device Power changes", + "DashboardFilesFilter": "Dashboard Files Filter", + "DashboardFilesFilterCompleted": "Completed", + "DashboardFilesFilterDescription": "Select which files should be displayed on the dashboard in the Status Panel.", + "DashboardFilesFilterFailed": "Failed", + "DashboardFilesFilterNew": "New", "DashboardFilesLimit": "Dashboard Files Limit", "DashboardFilesLimitDescription": "Select the maximum number of files to display on the dashboard in the Status Panel. (0 will hide the files tab)", "DashboardFilesLimitLabel": "{count} files", diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index d02de88b5..a9ffed150 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -184,6 +184,7 @@ export const getDefaultState = (): GuiState => { hideUpdateWarnings: false, printstatusThumbnailZoom: true, dashboardFilesLimit: 5, + dashboardFilesFilter: ['new', 'failed', 'completed'], }, view: { blockFileUpload: false, diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index 364c58725..e7f871344 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -126,6 +126,7 @@ export interface GuiState { hideUpdateWarnings: boolean printstatusThumbnailZoom: boolean dashboardFilesLimit: number + dashboardFilesFilter: GuiStateUiSettingsDashboardFilesFilter[] } view: { blockFileUpload: boolean @@ -215,3 +216,5 @@ export interface GuiStateLayoutoption { name: string visible: boolean } + +export type GuiStateUiSettingsDashboardFilesFilter = 'new' | 'failed' | 'completed' From 9fbc0a267ff793c93cb6db023fe9abb7b9c30a93 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 23 Nov 2024 14:09:24 +0100 Subject: [PATCH 3/3] locale(en): update locale file Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> --- src/locales/en.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 77dd1754b..3af1b9df3 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1231,11 +1231,11 @@ "ConfirmOnPowerDeviceChangeDescription": "Show a confirmation dialog on Device Power changes", "DashboardFilesFilter": "Dashboard Files Filter", "DashboardFilesFilterCompleted": "Completed", - "DashboardFilesFilterDescription": "Select which files should be displayed on the dashboard in the Status Panel.", + "DashboardFilesFilterDescription": "Filter the files in the Dashbord Status Panel by their last status.", "DashboardFilesFilterFailed": "Failed", "DashboardFilesFilterNew": "New", "DashboardFilesLimit": "Dashboard Files Limit", - "DashboardFilesLimitDescription": "Select the maximum number of files to display on the dashboard in the Status Panel. (0 will hide the files tab)", + "DashboardFilesLimitDescription": "Select the maximum number of files to display on the dashboard Status Panel. (0 hides the files tab)", "DashboardFilesLimitLabel": "{count} files", "DefaultNavigationState": "Navigation default state", "DefaultNavigationStateAlwaysClosed": "always closed",