diff --git a/src/components/settings/SettingsGeneralTab.vue b/src/components/settings/SettingsGeneralTab.vue index f0f892c6..49302579 100644 --- a/src/components/settings/SettingsGeneralTab.vue +++ b/src/components/settings/SettingsGeneralTab.vue @@ -10,6 +10,14 @@ + + + + + + + + @@ -117,6 +125,37 @@ export default class SettingsGeneralTab extends Mixins(BaseMixin) { return languages } + get calcEstimateItems() { + return [ + { value: 'file', text: 'File' }, + { value: 'filament', text: 'Filament' }, + ] + } + + get calcEstimateTime() { + return this.$store.state.gui.general.calcEstimateTime + } + + set calcEstimateTime(newVal) { + this.$store.dispatch('gui/saveSetting', {name: 'general.calcEstimateTime', value: newVal }) + } + + get calcEtaTimeItems() { + return [ + { value: 'file', text: 'File' }, + { value: 'filament', text: 'Filament' }, + { value: 'slicer', text: 'Slicer' }, + ] + } + + get calcEtaTime() { + return this.$store.state.gui.general.calcEtaTime + } + + set calcEtaTime(newVal) { + this.$store.dispatch('gui/saveSetting', {name: 'general.calcEtaTime', value: newVal }) + } + get boolBigThumbnail() { return this.$store.state.gui.dashboard.boolBigThumbnail } diff --git a/src/locales/en.json b/src/locales/en.json index 8a39393f..962e93e8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -498,6 +498,10 @@ "General": "General", "PrinterName": "Printer Name", "Language": "Language", + "CalcEstimateTime": "Estimate time calculation", + "CalcEstimateTimeDescription": "If multiple are selected, an average will be calculated", + "CalcEtaTime": "ETA calculation", + "CalcEtaTimeDescription": "If multiple are selected, an average will be calculated", "BoolBigThumbnail": "Large thumbnail", "BoolBigThumbnailDescription": "Display a large thumbnail in the status panel during a print.", "DisplayCANCEL_PRINT": "Display CANCEL_PRINT", diff --git a/src/store/farm/printer/getters.ts b/src/store/farm/printer/getters.ts index bbb0676c..710e3606 100644 --- a/src/store/farm/printer/getters.ts +++ b/src/store/farm/printer/getters.ts @@ -162,7 +162,7 @@ export const getters: GetterTree = { output.push({ name: 'ETA', - value: h+':'+m, + value: getters.estimated_time_eta > 0 ? h+':'+m : '--', file: getters.estimated_time_file, filament: getters.estimated_time_filament, slicer: getters.estimated_time_slicer, @@ -212,18 +212,21 @@ export const getters: GetterTree = { estimated_time_eta: (state, getters) => { let time = 0 let timeCount = 0 + const boolFileCalc = state.data.gui?.general?.calcEtaTime?.includes('file') ?? true + const boolFilamentCalc = state.data.gui?.general?.calcEtaTime?.includes('filament') ?? true + const boolSlicerCalc = state.data.gui?.general?.calcEtaTime?.includes('slicer') ?? true - if (getters.estimated_time_file > 0) { + if (boolFileCalc && getters.estimated_time_file > 0) { time += parseInt(getters.estimated_time_file) timeCount++ } - if (getters.estimated_time_filament > 0) { + if (boolFilamentCalc && getters.estimated_time_filament > 0) { time += parseInt(getters.estimated_time_filament) timeCount++ } - if (getters.estimated_time_slicer > 0) { + if (boolSlicerCalc && getters.estimated_time_slicer > 0) { time += parseInt(getters.estimated_time_slicer) timeCount++ } diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 48722490..e4a3ae50 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -14,6 +14,8 @@ export const getDefaultState = (): GuiState => { displayZOffsetStandby: false, confirmOnEmergencyStop: false, confirmOnPowerDeviceChange: false, + calcEstimateTime: ['file', 'filament'], + calcEtaTime: ['file', 'filament', 'slicer'], }, theme: { logo: defaultLogoColor, diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index 21184b1a..3f47deea 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -690,16 +690,18 @@ export const getters: GetterTree = { return 0 }, - getEstimatedTimeAvg: (state, getters) => { + getEstimatedTimeAvg: (state, getters, rootState) => { let time = 0 let timeCount = 0 + const boolFileCalc = rootState.gui?.general?.calcEstimateTime?.includes('file') ?? false + const boolFilamentCalc = rootState.gui?.general?.calcEstimateTime?.includes('filament') ?? false - if (getters.getEstimatedTimeFile > 0) { + if (boolFileCalc && getters.getEstimatedTimeFile > 0) { time += parseInt(getters.getEstimatedTimeFile) timeCount++ } - if (getters.getEstimatedTimeFilament > 0) { + if (boolFilamentCalc && getters.getEstimatedTimeFilament > 0) { time += parseInt(getters.getEstimatedTimeFilament) timeCount++ } @@ -709,21 +711,24 @@ export const getters: GetterTree = { return 0 }, - getEstimatedTimeETA: (state, getters) => { + getEstimatedTimeETA: (state, getters, rootState) => { let time = 0 let timeCount = 0 + const boolFileCalc = rootState.gui?.general?.calcEtaTime?.includes('file') ?? false + const boolFilamentCalc = rootState.gui?.general?.calcEtaTime?.includes('filament') ?? false + const boolSlicerCalc = rootState.gui?.general?.calcEtaTime?.includes('slicer') ?? false - if (getters.getEstimatedTimeFile > 0) { + if (boolFileCalc && getters.getEstimatedTimeFile > 0) { time += parseInt(getters.getEstimatedTimeFile) timeCount++ } - if (getters.getEstimatedTimeFilament > 0) { + if (boolFilamentCalc && getters.getEstimatedTimeFilament > 0) { time += parseInt(getters.getEstimatedTimeFilament) timeCount++ } - if (getters.getEstimatedTimeSlicer > 0) { + if (boolSlicerCalc && getters.getEstimatedTimeSlicer > 0) { time += parseInt(getters.getEstimatedTimeSlicer) timeCount++ }