From 08060611154a3251be02f237a037862c196f865e Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 28 Nov 2024 22:51:10 +0100 Subject: [PATCH] feat(StatusPanel): add option to show history in StatusPanel (#2055) Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> --- src/components/panels/Status/History.vue | 77 +++++ src/components/panels/Status/HistoryEntry.vue | 264 ++++++++++++++++++ src/components/panels/StatusPanel.vue | 19 +- .../settings/SettingsUiSettingsTab.vue | 22 ++ src/locales/en.json | 5 + src/store/gui/index.ts | 1 + src/store/gui/types.ts | 1 + src/store/server/history/types.ts | 4 + 8 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 src/components/panels/Status/History.vue create mode 100644 src/components/panels/Status/HistoryEntry.vue diff --git a/src/components/panels/Status/History.vue b/src/components/panels/Status/History.vue new file mode 100644 index 000000000..2ad17df2c --- /dev/null +++ b/src/components/panels/Status/History.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/components/panels/Status/HistoryEntry.vue b/src/components/panels/Status/HistoryEntry.vue new file mode 100644 index 000000000..7d5af2cb7 --- /dev/null +++ b/src/components/panels/Status/HistoryEntry.vue @@ -0,0 +1,264 @@ + + + + + diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 07b61d81d..6334d6eef 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -95,6 +95,9 @@ {{ mdiFileDocumentMultipleOutline }} + + {{ mdiHistory }} + {{ mdiTrayFull }} @@ -109,6 +112,9 @@ + + + @@ -129,6 +135,7 @@ import MinSettingsPanel from '@/components/panels/MinSettingsPanel.vue' import KlippyStatePanel from '@/components/panels/KlippyStatePanel.vue' import StatusPanelPrintstatus from '@/components/panels/Status/Printstatus.vue' import StatusPanelGcodefiles from '@/components/panels/Status/Gcodefiles.vue' +import StatusPanelHistory from '@/components/panels/Status/History.vue' import StatusPanelJobqueue from '@/components/panels/Status/Jobqueue.vue' import StatusPanelExcludeObject from '@/components/panels/Status/ExcludeObject.vue' import StatusPanelPrintstatusThumbnail from '@/components/panels/Status/PrintstatusThumbnail.vue' @@ -140,6 +147,7 @@ import { mdiCloseCircle, mdiDotsVertical, mdiFileDocumentMultipleOutline, + mdiHistory, mdiInformation, mdiLayersPlus, mdiMessageProcessingOutline, @@ -162,6 +170,7 @@ import CancelJobDialog from '@/components/dialogs/CancelJobDialog.vue' Panel, StatusPanelExcludeObject, StatusPanelGcodefiles, + StatusPanelHistory, StatusPanelJobqueue, StatusPanelPrintstatus, StatusPanelPrintstatusThumbnail, @@ -174,6 +183,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { mdiDotsVertical = mdiDotsVertical mdiFileDocumentMultipleOutline = mdiFileDocumentMultipleOutline mdiInformation = mdiInformation + mdiHistory = mdiHistory mdiMessageProcessingOutline = mdiMessageProcessingOutline mdiSpeedometer = mdiSpeedometer mdiTrayFull = mdiTrayFull @@ -378,9 +388,16 @@ export default class StatusPanel extends Mixins(BaseMixin) { return count > 0 } + get displayHistoryTab() { + const count = this.$store.state.gui.uiSettings.dashboardHistoryLimit ?? 5 + + return count > 0 + } + mounted() { if (this.current_filename !== '') this.activeTab = 'status' - if (!this.displayFilesTab) this.activeTab = 'jobqueue' + if (!this.displayFilesTab) this.activeTab = 'history' + if (!this.displayHistoryTab) this.activeTab = 'jobqueue' } @Watch('current_filename') diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 0d420a506..a05410af7 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -308,6 +308,20 @@ dense outlined /> + + + + @@ -674,6 +688,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin, ThemeMixin) ] } + get dashboardHistoryLimit() { + return this.$store.state.gui.uiSettings.dashboardHistoryLimit ?? 5 + } + + set dashboardHistoryLimit(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.dashboardHistoryLimit', 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 1108500a1..f65256eb8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -736,6 +736,7 @@ "ClearPrintStats": "Clear print stats", "Difference": "Difference", "EmptyGcodes": "No G-Code available.", + "EmptyHistory": "There is no job in the history.", "EmptyJobqueue": "There is currently no file in the job queue.", "Estimate": "Estimate", "ETA": "ETA", @@ -775,6 +776,7 @@ "Slicer": "Slicer", "Speed": "Speed", "Total": "Total", + "TotalTime": "Total Time", "Unknown": "Unknown" }, "TemperaturePanel": { @@ -1234,6 +1236,9 @@ "DashboardFilesLimit": "Dashboard Files Limit", "DashboardFilesLimitDescription": "Select the maximum number of files to display on the dashboard Status Panel. (0 hides the files tab)", "DashboardFilesLimitLabel": "{count} files", + "DashboardHistoryLimit": "Dashboard History Limit", + "DashboardHistoryLimitDescription": "Select the maximum number of jobs to display on the dashboard in the Status Panel. (0 hides the history tab)", + "DashboardHistoryLimitLabel": "{count} jobs", "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 a9ffed150..a7f011147 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -185,6 +185,7 @@ export const getDefaultState = (): GuiState => { printstatusThumbnailZoom: true, dashboardFilesLimit: 5, dashboardFilesFilter: ['new', 'failed', 'completed'], + dashboardHistoryLimit: 5, }, view: { blockFileUpload: false, diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index e7f871344..ed8f0dcda 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -127,6 +127,7 @@ export interface GuiState { printstatusThumbnailZoom: boolean dashboardFilesLimit: number dashboardFilesFilter: GuiStateUiSettingsDashboardFilesFilter[] + dashboardHistoryLimit: number } view: { blockFileUpload: boolean diff --git a/src/store/server/history/types.ts b/src/store/server/history/types.ts index 9cc07f8cd..090ae9649 100644 --- a/src/store/server/history/types.ts +++ b/src/store/server/history/types.ts @@ -91,3 +91,7 @@ export interface ServerHistoryStateAllPrintStatusEntry { } export type HistoryStatsValueNames = 'jobs' | 'filament' | 'time' + +export interface ServerHistoryStateJobWithCount extends ServerHistoryStateJob { + count: number +}