From 4f43c8929c15d4ac2ef652d5db8c051174c74413 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 29 Jan 2024 22:36:46 +0100 Subject: [PATCH] fix(timelapse): fix issue with changing timelapse settings (#1745) * fix(timelapse): fix issue with changing timelapse settings Signed-off-by: Stefan Dej * fix: add rules to timelapse setting inputs Signed-off-by: Stefan Dej * style: fix linter issue in locale en file Signed-off-by: Stefan Dej * locale(en): add missing translation Signed-off-by: Stefan Dej * Update src/locales/en.json Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> * update locales en Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> * style: run prettier Signed-off-by: Stefan Dej --------- Signed-off-by: Stefan Dej Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> --- .../settings/SettingsTimelapseTab.vue | 154 ++++++++++++++++-- src/locales/en.json | 5 + src/plugins/webSocketClient.ts | 9 +- 3 files changed, 150 insertions(+), 18 deletions(-) diff --git a/src/components/settings/SettingsTimelapseTab.vue b/src/components/settings/SettingsTimelapseTab.vue index b01dccf3e..13cc39b70 100644 --- a/src/components/settings/SettingsTimelapseTab.vue +++ b/src/components/settings/SettingsTimelapseTab.vue @@ -98,6 +98,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('stream_delay_compensation')" /> @@ -148,6 +152,15 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => + (v >= stepperXmin && v <= stepperXmax) || + $t('Settings.TimelapseTab.RulesBetweenMinMax', { + min: stepperXmin, + max: stepperXmax, + }), + ]" :disabled="blockedsettings.includes('park_custom_pos_x')" hide-spin-buttons /> @@ -164,6 +177,15 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => + (v >= stepperYmin && v <= stepperYmax) || + $t('Settings.TimelapseTab.RulesBetweenMinMax', { + min: stepperYmin, + max: stepperYmax, + }), + ]" :disabled="blockedsettings.includes('park_custom_pos_y')" hide-spin-buttons /> @@ -180,6 +202,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('park_custom_pos_dz')" hide-spin-buttons /> @@ -195,6 +221,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('park_travel_speed')" hide-spin-buttons /> @@ -221,6 +251,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('park_retract_speed')" hide-spin-buttons /> @@ -235,6 +269,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('park_retract_distance')" hide-spin-buttons /> @@ -249,6 +287,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('park_extrude_speed')" hide-spin-buttons /> @@ -263,6 +305,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('park_extrude_distance')" hide-spin-buttons /> @@ -279,6 +325,10 @@ step="0.1" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('park_time')" /> @@ -306,6 +356,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('targetlength')" hide-spin-buttons /> @@ -320,6 +374,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('variable_fps_min')" hide-spin-buttons /> @@ -334,6 +392,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > variable_fps_min || $t('Settings.TimelapseTab.RulesMin'), + ]" :disabled="blockedsettings.includes('variable_fps_max')" hide-spin-buttons /> @@ -350,6 +412,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('output_framerate')" hide-spin-buttons /> @@ -364,6 +430,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v >= 0 || $t('Settings.TimelapseTab.RulesZeroAndPositive'), + ]" :disabled="blockedsettings.includes('duplicatelastframe')" hide-spin-buttons /> @@ -377,6 +447,10 @@ hide-details="auto" outlined dense + :rules="[ + (v) => !!v || $t('Settings.TimelapseTab.RulesRequired'), + (v) => v > 0 || $t('Settings.TimelapseTab.RulesPositive'), + ]" :disabled="blockedsettings.includes('constant_rate_factor')" hide-spin-buttons /> @@ -542,7 +616,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.stream_delay_compensation } - set stream_delay_compensation(newVal) { + set stream_delay_compensation(newVal: number | string) { + if (newVal === '') newVal = 0 + this.$store.dispatch('server/timelapse/saveSetting', { stream_delay_compensation: newVal }) } @@ -582,23 +658,45 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_custom_pos_x } - set park_custom_pos_x(newVal) { + set park_custom_pos_x(newVal: number | string) { + if (newVal === '' || newVal < this.stepperXmin || newVal > this.stepperXmax) return + this.$store.dispatch('server/timelapse/saveSetting', { park_custom_pos_x: newVal }) } + get stepperXmin() { + return this.$store.state.printer.configfile?.settings?.stepper_x?.position_min ?? 0 + } + + get stepperXmax() { + return this.$store.state.printer.configfile?.settings?.stepper_x?.position_max ?? 200 + } + get park_custom_pos_y() { return this.$store.state.server.timelapse.settings.park_custom_pos_y } - set park_custom_pos_y(newVal) { + set park_custom_pos_y(newVal: number | string) { + if (newVal === '' || newVal < this.stepperYmin || newVal > this.stepperYmax) return + this.$store.dispatch('server/timelapse/saveSetting', { park_custom_pos_y: newVal }) } + get stepperYmin() { + return this.$store.state.printer.configfile?.settings?.stepper_y?.position_min ?? 0 + } + + get stepperYmax() { + return this.$store.state.printer.configfile?.settings?.stepper_y?.position_max ?? 200 + } + get park_custom_pos_dz() { return this.$store.state.server.timelapse.settings.park_custom_pos_dz } - set park_custom_pos_dz(newVal) { + set park_custom_pos_dz(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_custom_pos_dz: newVal }) } @@ -606,7 +704,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_travel_speed } - set park_travel_speed(newVal) { + set park_travel_speed(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_travel_speed: newVal }) } @@ -614,7 +714,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_retract_speed } - set park_retract_speed(newVal) { + set park_retract_speed(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_retract_speed: newVal }) } @@ -622,7 +724,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_extrude_speed } - set park_extrude_speed(newVal) { + set park_extrude_speed(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_extrude_speed: newVal }) } @@ -630,7 +734,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_retract_distance } - set park_retract_distance(newVal) { + set park_retract_distance(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_retract_distance: newVal }) } @@ -638,7 +744,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_extrude_distance } - set park_extrude_distance(newVal) { + set park_extrude_distance(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_extrude_distance: newVal }) } @@ -646,7 +754,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.park_time } - set park_time(newVal) { + set park_time(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { park_time: newVal }) } @@ -662,7 +772,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.constant_rate_factor } - set constant_rate_factor(newVal) { + set constant_rate_factor(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { constant_rate_factor: newVal }) } @@ -670,7 +782,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.output_framerate } - set output_framerate(newVal) { + set output_framerate(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { output_framerate: newVal }) } @@ -702,7 +816,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.targetlength } - set targetlength(newVal) { + set targetlength(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { targetlength: newVal }) } @@ -710,7 +826,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.variable_fps_min } - set variable_fps_min(newVal) { + set variable_fps_min(newVal: number | string) { + if (newVal === '' || newVal <= 0) return + this.$store.dispatch('server/timelapse/saveSetting', { variable_fps_min: newVal }) } @@ -718,7 +836,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.variable_fps_max } - set variable_fps_max(newVal) { + set variable_fps_max(newVal: number | string) { + if (newVal === '' || newVal <= this.variable_fps_min) return + this.$store.dispatch('server/timelapse/saveSetting', { variable_fps_max: newVal }) } @@ -726,7 +846,9 @@ export default class SettingsTimelapseTab extends Mixins(BaseMixin) { return this.$store.state.server.timelapse.settings.duplicatelastframe } - set duplicatelastframe(newVal) { + set duplicatelastframe(newVal: number | string) { + if (newVal === '' || newVal < 0) return + this.$store.dispatch('server/timelapse/saveSetting', { duplicatelastframe: newVal }) } diff --git a/src/locales/en.json b/src/locales/en.json index 8cb6bda38..b836bfd39 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1089,6 +1089,11 @@ "RetractDistanceDescription": "The length of filament that the extruder retracts.", "RetractSpeed": "Retract Speed", "RetractSpeedDescription": "Speed at which the extruder retracts the filament.", + "RulesBetweenMinMax": "Value must be between {min} and {max}!", + "RulesMin": "Value must be minimum {min}!", + "RulesPositive": "Value must be positive!", + "RulesRequired": "Value is required!", + "RulesZeroAndPositive": "Value must be 0 or greater!", "SaveFrames": "Save Frames", "SaveFramesDescription": "Save the frames to a zip-file for external rendering", "StreamDelayCompensation": "Stream Delay Compensation", diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index ffaee7b48..1208bb7cb 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -32,14 +32,19 @@ export class WebSocketClient { // report error messages if (data.error?.message) { // only report errors, if not disconnected and no init component - if (data.error?.message !== 'Klippy Disconnected' && !wait?.action?.startsWith('server/')) { + if (data.error?.message !== 'Klippy Disconnected') { window.console.error(`Response Error: ${data.error.message} (${wait?.action ?? 'no action'})`) } if (wait?.id) { const modulename = wait.action?.split('/')[1] ?? null - if (modulename && wait.action?.startsWith('server/') && initableServerComponents.includes(modulename)) { + if ( + modulename && + wait.action?.startsWith('server/') && + initableServerComponents.includes(modulename) && + this.store?.state.socket?.initializationList.length + ) { const component = wait.action.replace('server/', '').split('/')[0] window.console.error(`init server component ${component} failed`) this.store?.dispatch('server/addFailedInitComponent', component)