From 3dae42edb0dcecf3057fb194f81d0f5a147e8628 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 9 Oct 2021 23:39:06 +0200 Subject: [PATCH] feature: collapsable and normalize panels (#372) * feature: add panel component to normalize all panels * feature: add expand function to panel component * chore: remove not used computed value * feature: add slot for override the icon in the panel * chore: remove unused package (vue2-collapse) * feature: change StatusPanel.vue to panel component * feature: add prop to change toolbar color * feature: change MinSettingsPanel.vue to panel component * feature: change MoonrakerStatePanel.vue to panel component * feature: change KlippyStatePanel.vue to panel component * feature: change KlipperWarningsPanel.vue to panel component * feature: change ControlPanel.vue to panel component * feature: change PrintsettingsPanel.vue to panel component * feature: change MiscellaneousPanel.vue to panel component * feature: change ToolsPanel.vue to panel component * feature: change MacrosPanel.vue to panel component * feature: change MiniconsolePanel.vue to panel component * feature: change FarmPrinterPanel.vue to panel component * bugfix: add toolbar zindex to fix panel hover overlay * bugfix: remove toolbar zindex and modify hover effect * bugfix: farmprinter loading state (remove debug output) * feature: add prop to disable margin botton of panel component * feature: change HistoryListPanel.vue to panel component * feature: move history statistics in HistoryStatisticsPanel.vue and use panel component * feature: change ZoffsetPanel.vue to panel component * feature: add slot after toolbar title in panel component * feature: change Heightmap.vue to panel component * feature: change Files.vue to panel component * feature: change Viewer.vue to panel component * feature: add buttons before toolbar in panel component * feature: change ConfigFilesPanel.vue to panel component * feature: change EndstopPanel.vue to panel component * chore: fix typo in card class from ConfigFilesPanel.vue * feature: change LimitsPanel.vue to panel component * feature: change LogfilesPanel.vue to panel component * feature: change SystemPanel.vue to panel component * feature: change UpdatePanel.vue to panel component --- src/components/gcodeviewer/Viewer.vue | 18 +- src/components/panels/ControlPanel.vue | 20 +- src/components/panels/FarmPrinterPanel.vue | 27 +- src/components/panels/HistoryListPanel.vue | 279 +++++++++--------- .../panels/HistoryStatisticsPanel.vue | 119 ++++++++ .../panels/KlipperWarningsPanel.vue | 24 +- src/components/panels/KlippyStatePanel.vue | 17 +- .../panels/Machine/ConfigFilesPanel.vue | 74 ++--- .../panels/Machine/EndstopPanel.vue | 17 +- src/components/panels/Machine/LimitsPanel.vue | 12 +- .../panels/Machine/LogfilesPanel.vue | 15 +- src/components/panels/Machine/SystemPanel.vue | 129 ++++---- src/components/panels/Machine/UpdatePanel.vue | 33 +-- src/components/panels/MacrosPanel.vue | 21 +- src/components/panels/MinSettingsPanel.vue | 24 +- src/components/panels/MiniconsolePanel.vue | 17 +- src/components/panels/MiscellaneousPanel.vue | 18 +- src/components/panels/MoonrakerStatePanel.vue | 24 +- src/components/panels/PrintsettingsPanel.vue | 18 +- src/components/panels/StatusPanel.vue | 84 +++--- src/components/panels/ToolsPanel.vue | 21 +- src/components/panels/WebcamPanel.vue | 26 +- src/components/panels/ZoffsetPanel.vue | 34 +-- src/components/ui/Panel.vue | 71 +++++ src/locales/en.json | 1 + src/pages/Files.vue | 38 +-- src/pages/Heightmap.vue | 90 ++---- src/pages/History.vue | 115 +------- src/store/gui/actions.ts | 10 + src/store/gui/getters.ts | 4 + src/store/gui/index.ts | 3 +- src/store/gui/mutations.ts | 10 + src/store/server/actions.ts | 3 +- 33 files changed, 736 insertions(+), 680 deletions(-) create mode 100644 src/components/panels/HistoryStatisticsPanel.vue create mode 100644 src/components/ui/Panel.vue diff --git a/src/components/gcodeviewer/Viewer.vue b/src/components/gcodeviewer/Viewer.vue index 4181ffa6..35ec7a12 100644 --- a/src/components/gcodeviewer/Viewer.vue +++ b/src/components/gcodeviewer/Viewer.vue @@ -39,15 +39,11 @@ - + - - - - mdi-stack-overflow{{ $t('Heightmap.Profiles') }} - - + @@ -199,6 +159,7 @@ import { createComponent } from 'echarts-for-vue' import * as echarts from 'echarts' import {ECharts} from 'echarts/core' import 'echarts-gl' +import Panel from '@/components/ui/Panel.vue' interface HeightmapSerie { type: string @@ -216,6 +177,7 @@ interface HeightmapSerie { @Component({ components: { + Panel, ECharts: createComponent({ echarts }), } }) diff --git a/src/pages/History.vue b/src/pages/History.vue index 8d1923fa..f74e9f30 100644 --- a/src/pages/History.vue +++ b/src/pages/History.vue @@ -6,63 +6,10 @@
- - - - mdi-chart-areaspline{{ $t('History.Statistics') }} - - - - - - - - - {{ $t('History.TotalPrinttime') }} - {{ formatPrintTime(totalPrintTime) }} - - - {{ $t('History.LongestPrinttime') }} - {{ formatPrintTime(longestPrintTime) }} - - - {{ $t('History.AvgPrinttime') }} - {{ formatPrintTime(avgPrintTime) }} - - - {{ $t('History.TotalFilamentUsed') }} - {{ Math.round(totalFilamentUsed / 100) / 10 }} m - - - {{ $t('History.TotalJobs') }} - {{ totalJobsCount }} - - - - - - - - - - -
- - - {{ $t('History.FilamentUsage') }} - - - {{ $t('History.PrinttimeAvg') }} - - -
-
-
-
-
+
- + @@ -74,63 +21,15 @@ import {Component, Mixins} from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' -import HistoryAllPrintStatus from '@/components/charts/HistoryAllPrintStatus.vue' -import HistoryPrinttimeAvg from '@/components/charts/HistoryPrinttimeAvg.vue' -import HistoryFilamentUsage from '@/components/charts/HistoryFilamentUsage.vue' import HistoryListPanel from '@/components/panels/HistoryListPanel.vue' +import HistoryStatisticsPanel from '@/components/panels/HistoryStatisticsPanel.vue' @Component({ - components: {HistoryListPanel, HistoryFilamentUsage, HistoryPrinttimeAvg, HistoryAllPrintStatus} + components: { + HistoryStatisticsPanel, + HistoryListPanel + } }) export default class PageHistory extends Mixins(BaseMixin) { - get totalPrintTime() { - return 'total_print_time' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_print_time : 0 - } - - get longestPrintTime() { - return 'longest_print' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.longest_print : 0 - } - - get avgPrintTime() { - if (this.totalJobsCount > 0 && this.totalPrintTime > 0) return Math.round(this.totalPrintTime / this.totalJobsCount) - - return 0 - } - - get totalFilamentUsed() { - return 'total_filament_used' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_filament_used : 0 - } - - get totalJobsCount() { - return 'total_jobs' in this.$store.state.server.history.job_totals ? this.$store.state.server.history.job_totals.total_jobs : 0 - } - - get toggleChart () { - return this.$store.state.gui.history.toggleChartCol3 - } - - set toggleChart(newVal) { - this.$store.dispatch('gui/saveSetting', { name: 'history.toggleChartCol3', value: newVal }) - } - - formatPrintTime(totalSeconds: number) { - if (totalSeconds) { - let output = '' - - const hours = Math.floor(totalSeconds / 3600) - totalSeconds %= 3600 - if (hours) output += ' '+hours+'h' - - const minutes = Math.floor(totalSeconds / 60) - if (minutes) output += ' '+minutes+'m' - - const seconds = totalSeconds % 60 - if (seconds) output += ' '+seconds.toFixed(0)+'s' - - return output - } - - return '--' - } } diff --git a/src/store/gui/actions.ts b/src/store/gui/actions.ts index e1705ae2..746aed5e 100644 --- a/src/store/gui/actions.ts +++ b/src/store/gui/actions.ts @@ -191,6 +191,16 @@ export const actions: ActionTree = { } }, + saveExpandPanel({ commit, dispatch, state }, payload) { + if (!payload.value) commit('addClosePanel', { name: payload.name }) + else commit('removeClosePanel', { name: payload.name }) + + dispatch('updateSettings', { + keyName: 'dashboard.nonExpandPanels', + newVal: state.dashboard.nonExpandPanels + }) + }, + showStatusInHistoryList({ commit, dispatch, state }, name) { const array: string[] = [...state.history.hidePrintStatus] diff --git a/src/store/gui/getters.ts b/src/store/gui/getters.ts index c7a2e0cb..30aa91fa 100644 --- a/src/store/gui/getters.ts +++ b/src/store/gui/getters.ts @@ -102,5 +102,9 @@ export const getters: GetterTree = { return 0 }) + }, + + getPanelExpand: (state) => (name: string) => { + return !state.dashboard.nonExpandPanels?.includes(name) ?? true } } diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 3cae369f..0ecdfb3d 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -89,7 +89,8 @@ export const getDefaultState = (): GuiState => { widescreenLayout3: [ { 'name': 'webcam', visable: true }, { 'name': 'miniconsole', visable: true }, - ] + ], + nonExpandPanels: [] }, webcam: { selectedCam: '', diff --git a/src/store/gui/mutations.ts b/src/store/gui/mutations.ts index 7ff30698..143739ec 100644 --- a/src/store/gui/mutations.ts +++ b/src/store/gui/mutations.ts @@ -152,5 +152,15 @@ export const mutations: MutationTree = { setHistoryHidePrintStatus(state, payload) { Vue.set(state.history, 'hidePrintStatus', payload) + }, + + addClosePanel(state, payload) { + const exist = state.dashboard.nonExpandPanels?.includes(payload.name) ?? false + if (!exist) state.dashboard.nonExpandPanels.push(payload.name) + }, + + removeClosePanel(state, payload) { + const index = state.dashboard.nonExpandPanels.indexOf(payload.name) + if (index > -1) state.dashboard.nonExpandPanels.splice(index, 1) } } diff --git a/src/store/server/actions.ts b/src/store/server/actions.ts index b048ff53..5b585525 100644 --- a/src/store/server/actions.ts +++ b/src/store/server/actions.ts @@ -62,7 +62,8 @@ export const actions: ActionTree = { }, initProcStats({ commit }, payload) { - commit('setThrottledState', payload.throttled_state) + if (payload.throttled_state !== null) + commit('setThrottledState', payload.throttled_state) }, setKlippyReady({ dispatch }) {