From 3b10ec790ed2bb7c8a30624f95e77b2875835029 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 9 Jan 2024 22:06:10 +0100 Subject: [PATCH 1/7] fix(timelapse): fix issue with changing timelapse settings Signed-off-by: Stefan Dej --- src/plugins/webSocketClient.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index 2fdb3e0ad..2f14e6964 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -63,7 +63,7 @@ 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'})`) } @@ -73,7 +73,8 @@ export class WebSocketClient { if ( modulename && wait.action?.startsWith('server/') && - initableServerComponents.includes(modulename) + 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`) From bde8f535cdbfc4ae75dd59744789262d94266fbc Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 12 Jan 2024 21:57:19 +0100 Subject: [PATCH 2/7] fix: add rules to timelapse setting inputs Signed-off-by: Stefan Dej --- .../settings/SettingsTimelapseTab.vue | 154 ++++++++++++++++-- src/locales/en.json | 4 + 2 files changed, 142 insertions(+), 16 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..2742527db 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1089,6 +1089,10 @@ "RetractDistanceDescription": "The length of filament that the extruder retracts.", "RetractSpeed": "Retract Speed", "RetractSpeedDescription": "Speed at which the extruder retracts the filament.", + "RulesBetweenMinMax": "This value has to be between {min} and {max}!", + "RulesRequired": "This value is required!", + "RulesPositive": "This value has to be positive!", + "RulesZeroAndPositive": "This value has to be 0 or above!", "SaveFrames": "Save Frames", "SaveFramesDescription": "Save the frames to a zip-file for external rendering", "StreamDelayCompensation": "Stream Delay Compensation", From 02be0d4fc08339a834c4808fedd68ff2860f6d6c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 12 Jan 2024 22:12:44 +0100 Subject: [PATCH 3/7] style: fix linter issue in locale en file Signed-off-by: Stefan Dej --- src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index 2742527db..0eff6fa0f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1090,8 +1090,8 @@ "RetractSpeed": "Retract Speed", "RetractSpeedDescription": "Speed at which the extruder retracts the filament.", "RulesBetweenMinMax": "This value has to be between {min} and {max}!", - "RulesRequired": "This value is required!", "RulesPositive": "This value has to be positive!", + "RulesRequired": "This value is required!", "RulesZeroAndPositive": "This value has to be 0 or above!", "SaveFrames": "Save Frames", "SaveFramesDescription": "Save the frames to a zip-file for external rendering", From cff560a95645a025644584768c8a2c0faab82af9 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 12 Jan 2024 22:17:09 +0100 Subject: [PATCH 4/7] locale(en): add missing translation Signed-off-by: Stefan Dej --- src/locales/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/en.json b/src/locales/en.json index 0eff6fa0f..dcc862786 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1090,6 +1090,7 @@ "RetractSpeed": "Retract Speed", "RetractSpeedDescription": "Speed at which the extruder retracts the filament.", "RulesBetweenMinMax": "This value has to be between {min} and {max}!", + "RulesMin": "This value has to be minimum {min}!", "RulesPositive": "This value has to be positive!", "RulesRequired": "This value is required!", "RulesZeroAndPositive": "This value has to be 0 or above!", From 4a82d36ee5a48065198228499f6a3d1361de079f Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 28 Jan 2024 22:32:31 +0100 Subject: [PATCH 5/7] Update src/locales/en.json Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> --- src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index dcc862786..07831ccf9 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1093,7 +1093,7 @@ "RulesMin": "This value has to be minimum {min}!", "RulesPositive": "This value has to be positive!", "RulesRequired": "This value is required!", - "RulesZeroAndPositive": "This value has to be 0 or above!", + "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", From bfe0ee866bb159898c965e94a822547f739d071c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 28 Jan 2024 22:33:17 +0100 Subject: [PATCH 6/7] update locales en Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com> --- src/locales/en.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 07831ccf9..b836bfd39 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1089,10 +1089,10 @@ "RetractDistanceDescription": "The length of filament that the extruder retracts.", "RetractSpeed": "Retract Speed", "RetractSpeedDescription": "Speed at which the extruder retracts the filament.", - "RulesBetweenMinMax": "This value has to be between {min} and {max}!", - "RulesMin": "This value has to be minimum {min}!", - "RulesPositive": "This value has to be positive!", - "RulesRequired": "This value is required!", + "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", From 31141c692f168e169a859ef1fb7df8bdf45eb5be Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 28 Jan 2024 23:12:46 +0100 Subject: [PATCH 7/7] style: run prettier Signed-off-by: Stefan Dej --- src/plugins/webSocketClient.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index a1dace98d..1208bb7cb 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -29,27 +29,27 @@ export class WebSocketClient { handleMessage(data: any) { const wait = this.getWaitById(data.id) - // report error messages - if (data.error?.message) { - // only report errors, if not disconnected and no init component - if (data.error?.message !== 'Klippy Disconnected') { - window.console.error(`Response Error: ${data.error.message} (${wait?.action ?? 'no action'})`) - } + // report error messages + if (data.error?.message) { + // only report errors, if not disconnected and no init component + 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) && - 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) - this.store?.dispatch('socket/removeInitComponent', `server/${component}/`) - } + 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) + this.store?.dispatch('socket/removeInitComponent', `server/${component}/`) + } this.removeWaitById(wait.id) }