From f4bbe45c2508227746d6b70357856eabc899d17f Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 11 Sep 2024 22:44:39 +0200 Subject: [PATCH 1/8] feat: add heartbeat to the moonraker websocket (#2003) --- src/plugins/webSocketClient.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index 6e4820240..a2a6addbc 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -14,6 +14,7 @@ export class WebSocketClient { timerId: number | null = null store: Store | null = null waits: Wait[] = [] + heartbeatTimer: number | null = null constructor(options: WebSocketPluginOptions) { this.url = options.url @@ -89,7 +90,7 @@ export class WebSocketClient { isConnecting: true, }) - await this.instance?.close() + this.instance?.close() this.instance = new WebSocket(this.url) this.instance.onopen = () => { @@ -116,14 +117,19 @@ export class WebSocketClient { this.instance.onmessage = (msg) => { if (this.store === null) return + // websocket is alive + this.heartbeat() + const data = JSON.parse(msg.data) if (Array.isArray(data)) { for (const message of data) { this.handleMessage(message) } - } else { - this.handleMessage(data) + + return } + + this.handleMessage(data) } } @@ -194,6 +200,17 @@ export class WebSocketClient { this.instance.send(JSON.stringify(body)) } + + heartbeat(): void { + if (this.heartbeatTimer) clearInterval(this.heartbeatTimer) + + this.heartbeatTimer = window.setTimeout(() => { + if (this.instance?.readyState !== WebSocket.OPEN || !this.store) return + + this.close() + this.store?.dispatch('socket/onClose') + }, 10000) + } } export function WebSocketPlugin(Vue: typeof _Vue, options: WebSocketPluginOptions): void { From f1085452233f5d59e312aa9d379cb1c6ea58404b Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 11 Sep 2024 22:44:57 +0200 Subject: [PATCH 2/8] fix(ExtruderPanel): fix extrude and speed factor output (#2002) --- .../panels/Extruder/EstimatedExtrusionOutput.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/panels/Extruder/EstimatedExtrusionOutput.vue b/src/components/panels/Extruder/EstimatedExtrusionOutput.vue index 2ce18edae..bce476324 100644 --- a/src/components/panels/Extruder/EstimatedExtrusionOutput.vue +++ b/src/components/panels/Extruder/EstimatedExtrusionOutput.vue @@ -16,10 +16,10 @@
- {{ $t('Panels.ToolheadControlPanel.SpeedFactor') }}: {{ speed_factor * 100 }} % + {{ $t('Panels.ToolheadControlPanel.SpeedFactor') }}: {{ speedFactorOutput }} %
- {{ $t('Panels.ExtruderControlPanel.ExtrusionFactor') }}: {{ extrudeFactor * 100 }} % + {{ $t('Panels.ExtruderControlPanel.ExtrusionFactor') }}: {{ extrudeFactorOutput }} %
@@ -64,5 +64,13 @@ export default class PressureAdvanceSettings extends Mixins(BaseMixin, ExtruderM get showTooltip() { return this.speed_factor !== 1 || this.extrudeFactor !== 1 } + + get speedFactorOutput() { + return (this.speed_factor * 100).toFixed(0) + } + + get extrudeFactorOutput() { + return (this.extrudeFactor * 100).toFixed(0) + } } From 682a3dce6bc97d8eea0c344499bf1f7a68d3006e Mon Sep 17 00:00:00 2001 From: "Michal Dziekonski (mdz)" Date: Sun, 15 Sep 2024 11:19:37 +0200 Subject: [PATCH 3/8] fix(Editor): Trigger gotoLine only when change is from sidebar (#2012) --- src/components/TheEditor.vue | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/TheEditor.vue b/src/components/TheEditor.vue index 215ed1ccd..dce57ec45 100644 --- a/src/components/TheEditor.vue +++ b/src/components/TheEditor.vue @@ -67,14 +67,15 @@ dense :active="structureActive" :open="structureOpen" - item-key="line" + :item-key="treeviewItemKeyProp" :items="configFileStructure" class="w-100" @update:active="activeChanges"> @@ -188,8 +189,10 @@ export default class TheEditor extends Mixins(BaseMixin) { dialogConfirmChange = false dialogDevices = false fileStructureSidebar = true + treeviewItemKeyProp = 'line' as const structureActive: number[] = [] structureOpen: number[] = [] + structureActiveChangedBySidebar: boolean = false formatFilesize = formatFilesize @@ -424,8 +427,23 @@ export default class TheEditor extends Mixins(BaseMixin) { this.fileStructureSidebar = !this.fileStructureSidebar } - activeChanges(key: any) { - this.editor?.gotoLine(key) + // Relies on event bubbling to flip the flag before treeview active change is handled + activeChangesItemClick() { + this.structureActiveChangedBySidebar = true + } + + activeChanges(activeItems: Array) { + if (!this.structureActiveChangedBySidebar) { + return + } + + this.structureActiveChangedBySidebar = false + + if (!activeItems.length) { + return + } + + this.editor?.gotoLine(activeItems[0]) } lineChanges(line: number) { From 2a49060962fafd8ead55d26d1dda56604d53b910 Mon Sep 17 00:00:00 2001 From: "Michal Dziekonski (mdz)" Date: Sun, 15 Sep 2024 12:12:26 +0200 Subject: [PATCH 4/8] fix(HistoryPanel): Fix History thumbnails of files in folders (#2010) --- .../panels/History/HistoryListEntryJob.vue | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/components/panels/History/HistoryListEntryJob.vue b/src/components/panels/History/HistoryListEntryJob.vue index aa8da85d9..d6444cfc4 100644 --- a/src/components/panels/History/HistoryListEntryJob.vue +++ b/src/components/panels/History/HistoryListEntryJob.vue @@ -134,6 +134,7 @@ import { Component, Mixins, Prop } from 'vue-property-decorator' import HistoryListPanelDetailsDialog from '@/components/dialogs/HistoryListPanelDetailsDialog.vue' import Panel from '@/components/ui/Panel.vue' import BaseMixin from '@/components/mixins/base' +import { FileStateFileThumbnail } from '@/store/files/types' import { ServerHistoryStateJob } from '@/store/server/history/types' import { thumbnailBigMin, thumbnailSmallMax, thumbnailSmallMin } from '@/store/variables' import { @@ -187,40 +188,22 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { if ((this.item.metadata?.thumbnails?.length ?? 0) < 1) return false const thumbnail = this.item.metadata?.thumbnails?.find( - (thumb: any) => + (thumb) => thumb.width >= thumbnailSmallMin && thumb.width <= thumbnailSmallMax && thumb.height >= thumbnailSmallMin && thumb.height <= thumbnailSmallMax ) - let relative_url = '' - if (this.item.filename.lastIndexOf('/') !== -1) { - relative_url = this.item.filename.substring(0, this.item.filename.lastIndexOf('/')) - } - - if ((thumbnail?.relative_path ?? null) === null) return false - - return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url + thumbnail?.relative_path)}?timestamp=${ - this.item.metadata.modified - }` + return thumbnail ? this.createThumbnailUrl(thumbnail) : false } get bigThumbnail() { if ((this.item.metadata?.thumbnails?.length ?? 0) < 1) return false - const thumbnail = this.item.metadata?.thumbnails?.find((thumb: any) => thumb.width >= thumbnailBigMin) - - let relative_url = '' - if (this.item.filename.lastIndexOf('/') !== -1) { - relative_url = this.item.filename.substring(0, this.item.filename.lastIndexOf('/') + 1) - } - - if ((thumbnail?.relative_path ?? null) === null) return false + const thumbnail = this.item.metadata?.thumbnails?.find((thumb) => thumb.width >= thumbnailBigMin) - return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url + thumbnail?.relative_path)}?timestamp=${ - this.item.metadata.modified - }` + return thumbnail ? this.createThumbnailUrl(thumbnail) : false } get statusIcon() { @@ -331,5 +314,16 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { return value } } + + createThumbnailUrl(thumbnail: FileStateFileThumbnail) { + let relative_url = '' + if (this.item.filename.lastIndexOf('/') !== -1) { + relative_url = this.item.filename.substring(0, this.item.filename.lastIndexOf('/') + 1) + } + + return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url + thumbnail.relative_path)}?timestamp=${ + this.item.metadata.modified + }` + } } From f4ee321c4e85abf5eb30bec9be2a39c6604f9b2e Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 15 Sep 2024 14:52:15 +0200 Subject: [PATCH 5/8] fix(webcam): fix some connection issues in Camera-Streamer (#1981) --- src/components/webcams/WebcamWrapperItem.vue | 2 +- .../streamers/WebrtcCameraStreamer.vue | 277 +++++++++++------- 2 files changed, 167 insertions(+), 112 deletions(-) diff --git a/src/components/webcams/WebcamWrapperItem.vue b/src/components/webcams/WebcamWrapperItem.vue index 00d4a9078..caf299a05 100644 --- a/src/components/webcams/WebcamWrapperItem.vue +++ b/src/components/webcams/WebcamWrapperItem.vue @@ -19,7 +19,7 @@