From accde2227bf62b9c6f66c57f0eca48b7667917d4 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 5 Jul 2020 23:41:39 +0200 Subject: [PATCH] Update to Moonraker .08-alpha --- src/App.vue | 2 +- src/components/panels/ControlPanel.vue | 12 +++--- src/components/panels/ExtruderPanel.vue | 4 +- .../panels/Settings/EndstopPanel.vue | 2 +- .../panels/Settings/SystemPanel.vue | 12 +++--- src/components/panels/ZOffsetPanel.vue | 4 +- src/inputs/SettingsRunoutSwitch.vue | 2 +- src/inputs/ToolInput.vue | 2 +- src/inputs/ToolSlider.vue | 2 +- src/pages/Console.vue | 2 +- src/pages/Files.vue | 6 +-- src/plugins/wsClient.js | 12 ++++-- src/store/actions.js | 42 +++++++++---------- src/store/getters.js | 12 +++--- src/store/mutations.js | 4 +- 15 files changed, 61 insertions(+), 59 deletions(-) diff --git a/src/App.vue b/src/App.vue index 19eef53a..749b4a20 100644 --- a/src/App.vue +++ b/src/App.vue @@ -129,7 +129,7 @@ export default { methods: { emergencyStop: function() { this.$store.commit('setLoadingEmergencyStop', true); - this.$socket.sendObj('post_printer_gcode', {script: 'M112'}, 'setLoadingEmergencyStop'); + this.$socket.sendObj('post_printer_gcode_script', {script: 'M112'}, 'setLoadingEmergencyStop'); }, drawFavicon(val) { let favicon = document.getElementById('favicon'); diff --git a/src/components/panels/ControlPanel.vue b/src/components/panels/ControlPanel.vue index 9bb5faf7..46f93b4e 100644 --- a/src/components/panels/ControlPanel.vue +++ b/src/components/panels/ControlPanel.vue @@ -94,27 +94,27 @@ doHome() { this.$store.commit('addGcodeResponse', "G28"); this.$store.commit('setLoading', { name: 'controlHomeAll' }); - this.$socket.sendObj('post_printer_gcode', { script: "G28" }, "responseHome"); + this.$socket.sendObj('post_printer_gcode_script', { script: "G28" }, "responseHome"); }, doHomeX() { this.$store.commit('addGcodeResponse', "G28 X"); this.$store.commit('setLoading', { name: 'controlHomeX' }); - this.$socket.sendObj('post_printer_gcode', { script: "G28 X" }, "responseHomeX"); + this.$socket.sendObj('post_printer_gcode_script', { script: "G28 X" }, "responseHomeX"); }, doHomeY() { this.$store.commit('addGcodeResponse', "G28 Y"); this.$store.commit('setLoading', { name: 'controlHomeY' }); - this.$socket.sendObj('post_printer_gcode', { script: "G28 Y" }, "responseHomeY"); + this.$socket.sendObj('post_printer_gcode_script', { script: "G28 Y" }, "responseHomeY"); }, doHomeZ() { this.$store.commit('addGcodeResponse', "G28 Z"); this.$store.commit('setLoading', { name: 'controlHomeZ' }); - this.$socket.sendObj('post_printer_gcode', { script: "G28 Z" }, "responseHomeZ"); + this.$socket.sendObj('post_printer_gcode_script', { script: "G28 Z" }, "responseHomeZ"); }, doQGL() { this.$store.commit('addGcodeResponse', "QUAD_GANTRY_LEVEL"); this.$store.commit('setLoadingQGL', true); - this.$socket.sendObj('post_printer_gcode', { script: "QUAD_GANTRY_LEVEL" }, "responseQGL"); + this.$socket.sendObj('post_printer_gcode_script', { script: "QUAD_GANTRY_LEVEL" }, "responseQGL"); }, doSendMove(gcode) { gcode = "G91" + "\n" + @@ -125,7 +125,7 @@ }, doSend(gcode) { this.$store.commit('addGcodeResponse', gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "sendGcode"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "sendGcode"); }, }, watch: { diff --git a/src/components/panels/ExtruderPanel.vue b/src/components/panels/ExtruderPanel.vue index f093312b..fb841bb3 100644 --- a/src/components/panels/ExtruderPanel.vue +++ b/src/components/panels/ExtruderPanel.vue @@ -82,13 +82,13 @@ let gcode = "M120\nM83\nG1 E-"+this.feedAmount+" F"+(this.feedrate * 60)+"\nM121"; this.$store.commit('setLoading', { name: 'extruderRetract' }); this.$store.commit('addGcodeResponse', gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeExtruderRetract"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeExtruderRetract"); }, sendDetract() { let gcode = "M120\nM83\nG1 E"+this.feedAmount+" F"+(this.feedrate * 60)+"\nM121"; this.$store.commit('setLoading', { name: 'extruderDetract' }); this.$store.commit('addGcodeResponse', gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeExtruderDetract"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeExtruderDetract"); }, }, watch: { diff --git a/src/components/panels/Settings/EndstopPanel.vue b/src/components/panels/Settings/EndstopPanel.vue index f5045de0..cffecc78 100644 --- a/src/components/panels/Settings/EndstopPanel.vue +++ b/src/components/panels/Settings/EndstopPanel.vue @@ -53,7 +53,7 @@ methods: { syncEndstops() { this.$store.commit('setLoadingEndstopStatus', true); - this.$socket.sendObj('get_printer_endstops', { }, "responseEndstopStatus"); + this.$socket.sendObj('get_printer_query_endstops_status', { }, "responseEndstopStatus"); } }, watch: { diff --git a/src/components/panels/Settings/SystemPanel.vue b/src/components/panels/Settings/SystemPanel.vue index 060df87e..6b84dc04 100644 --- a/src/components/panels/Settings/SystemPanel.vue +++ b/src/components/panels/Settings/SystemPanel.vue @@ -7,13 +7,13 @@ - -
mdi-downloadKlipper Log
-
mdi-downloadMoonraker Log
+ +
mdi-downloadKlipper Log
+
mdi-downloadMoonraker Log
mdi-cachedRestart
-
mdi-cachedFW Restart
-
mdi-cachedHost Restart
-
mdi-powerHost Shutdown
+
mdi-cachedFW Restart
+
mdi-cachedHost Restart
+
mdi-powerHost Shutdown
diff --git a/src/components/panels/ZOffsetPanel.vue b/src/components/panels/ZOffsetPanel.vue index 1e44329a..f34ec5ec 100644 --- a/src/components/panels/ZOffsetPanel.vue +++ b/src/components/panels/ZOffsetPanel.vue @@ -54,13 +54,13 @@ let gcode = "SET_GCODE_OFFSET Z_ADJUST=-0.05 MOVE=1"; this.$store.commit('setLoading', { name: 'babySteppingDown' }); this.$store.commit('addGcodeResponse', gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeBabySteppingDown"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeBabySteppingDown"); }, sendBabySteppingUp() { let gcode = "SET_GCODE_OFFSET Z_ADJUST=0.05 MOVE=1"; this.$store.commit('setLoading', { name: 'babySteppingUp' }); this.$store.commit('addGcodeResponse', gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: gcode }, "respondeBabySteppingUp"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: gcode }, "respondeBabySteppingUp"); }, }, watch: { diff --git a/src/inputs/SettingsRunoutSwitch.vue b/src/inputs/SettingsRunoutSwitch.vue index 2ace6ed4..c7530179 100644 --- a/src/inputs/SettingsRunoutSwitch.vue +++ b/src/inputs/SettingsRunoutSwitch.vue @@ -42,7 +42,7 @@ }, methods: { changeSensor() { - this.$socket.sendObj('post_printer_gcode', { script: 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.enabled ? 0 : 1) }); + this.$socket.sendObj('post_printer_gcode_script', { script: 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.enabled ? 0 : 1) }); } }, watch: { diff --git a/src/inputs/ToolInput.vue b/src/inputs/ToolInput.vue index e5653715..fbe97a6d 100644 --- a/src/inputs/ToolInput.vue +++ b/src/inputs/ToolInput.vue @@ -33,7 +33,7 @@ }, methods: { setTemps() { - this.$socket.sendObj('post_printer_gcode', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value}); + this.$socket.sendObj('post_printer_gcode_script', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value}); } }, watch: { diff --git a/src/inputs/ToolSlider.vue b/src/inputs/ToolSlider.vue index 2140202c..e5fb389e 100644 --- a/src/inputs/ToolSlider.vue +++ b/src/inputs/ToolSlider.vue @@ -69,7 +69,7 @@ }, methods: { sendCmd() { - this.$socket.sendObj('post_printer_gcode', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) }); + this.$socket.sendObj('post_printer_gcode_script', { script: this.command+' '+this.attributeName+(this.value*this.attributeScale).toFixed(0) }); }, decrement() { this.value--; diff --git a/src/pages/Console.vue b/src/pages/Console.vue index 9b231e7c..bb454e69 100644 --- a/src/pages/Console.vue +++ b/src/pages/Console.vue @@ -134,7 +134,7 @@ doSend() { this.loadingSendGcode = true; this.$store.commit('addGcodeResponse', this.gcode); - Vue.prototype.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode"); + Vue.prototype.$socket.sendObj('post_printer_gcode_script', { script: this.gcode }, "sendGcode"); this.lastCommands.push(this.gcode); this.gcode = ""; this.lastCommandNumber = null; diff --git a/src/pages/Files.vue b/src/pages/Files.vue index 5f2e8fec..55889092 100644 --- a/src/pages/Files.vue +++ b/src/pages/Files.vue @@ -220,7 +220,7 @@ formData.append('file', file); this.$store.commit('setLoadingGcodeUpload', true); - axios.post('http://' + this.hostname + ':' + this.port + '/printer/files/upload', + axios.post('http://' + this.hostname + ':' + this.port + '/server/files/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' } } @@ -238,7 +238,7 @@ }, refreshFileList: function() { this.$store.commit('setLoadingGcodeRefresh', true); - this.$socket.sendObj('get_printer_files', {}, 'getFileList'); + this.$socket.sendObj('get_file_list', {}, 'getFileList'); }, formatDate(date) { let tmp2 = new Date(date); @@ -292,7 +292,7 @@ }, removeFile() { axios.delete( - 'http://'+ this.hostname + ':' + this.port +'/printer/files/'+this.contextMenu.item.filename + 'http://'+ this.hostname + ':' + this.port +'/server/files/'+this.contextMenu.item.filename ).then((result) => { this.$toast.success(result.data.result+" successfully deleted."); }).catch(() => { diff --git a/src/plugins/wsClient.js b/src/plugins/wsClient.js index 2d766c0d..1249bb6c 100644 --- a/src/plugins/wsClient.js +++ b/src/plugins/wsClient.js @@ -59,10 +59,14 @@ export default class WebSocketClient { if (this.store) { if (this.wsData.filter(item => item.id === data.id).length > 0 && this.wsData.filter(item => item.id === data.id)[0].action !== "") { - this.store.dispatch( - this.wsData.filter(item => item.id === data.id)[0].action, - data.result - ) + if (data.error && data.error.message) { + window.console.error("Response Error: "+this.wsData.filter(item => item.id === data.id)[0].action+" > "+data.error.message); + } else { + this.store.dispatch( + this.wsData.filter(item => item.id === data.id)[0].action, + data.result + ) + } } else this.passToStore('socket_on_message', data) } }; diff --git a/src/store/actions.js b/src/store/actions.js index b778e111..f7de4c3a 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -7,25 +7,16 @@ import axios from "axios"; export default { socket_on_open ({ commit }) { commit('setConnected'); - Vue.prototype.$socket.sendObj('get_printer_status', { }, 'getHelpData'); - - fetch('http://'+store.state.socket.hostname+':'+store.state.socket.port+'/printer/files/gui.json') - .then(res => res.json()).then(file => { - store.commit('setSettings', file); - }).catch(function() { - window.console.warn('No mainsail config file found.'); - }); - + Vue.prototype.$socket.sendObj('get_printer_objects_status', { }, 'getHelpData'); + Vue.prototype.$socket.sendObj('get_directory', { path: 'gcodes' }, 'getDirectoryRoot'); Vue.prototype.$socket.sendObj('get_printer_info', {}, 'getKlipperInfo'); }, socket_on_close ({ commit }, event) { commit('setDisconnected'); - if (event.wasClean) { - window.console.log('Socket closed clear') - } else { - window.console.error('Connection failure') - } + if (event.wasClean) window.console.log('Socket closed clear') + else window.console.error('Connection failure') + window.console.error('Code: ' + event.code) }, @@ -58,13 +49,20 @@ export default { default: if (data.result !== "ok") { - window.console.log("Default return"); if (data.error) window.console.error("JSON-RPC: " + data.error.message); - else window.console.log(data); } } }, + getDirectoryRoot({ commit }, data) { + if (data.files && data.files.filter((file) => file.filename === "gui.json")) { + fetch('http://'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/gcodes/gui.json') + .then(res => res.json()).then(file => { + commit('setSettings', file); + }); + } + }, + saveGuiSettings({ commit, state }) { commit('setLoadingSaveGuiConfige', true); let file = new File([JSON.stringify({ webcam: state.webcam, gui: state.gui })], 'gui.json'); @@ -92,10 +90,10 @@ export default { commit('setPrinterStatus', 'ready'); - Vue.prototype.$socket.sendObj('get_printer_objects', {}, 'getObjectInfo'); - Vue.prototype.$socket.sendObj('get_printer_status', { heaters: [] }, 'getHeatersInfo'); - Vue.prototype.$socket.sendObj('get_printer_status', { configfile: ['config'] }, 'getPrinterConfig'); - Vue.prototype.$socket.sendObj('post_printer_subscriptions', { + Vue.prototype.$socket.sendObj('get_printer_objects_list', {}, 'getObjectInfo'); + Vue.prototype.$socket.sendObj('get_printer_objects_status', { heaters: [] }, 'getHeatersInfo'); + Vue.prototype.$socket.sendObj('get_printer_objects_status', { configfile: ['config'] }, 'getPrinterConfig'); + Vue.prototype.$socket.sendObj('post_printer_objects_subscription', { gcode: [], toolhead: [], virtual_sdcard: [], @@ -105,7 +103,7 @@ export default { idle_timeout: [], display_status: [], }); - Vue.prototype.$socket.sendObj('get_printer_files', {}, 'getFileList'); + Vue.prototype.$socket.sendObj('get_file_list', {}, 'getFileList'); Vue.prototype.$socket.sendObj('get_printer_gcode_help', {}, 'getHelpList'); } else { commit('setPrinterStatus', 'disconnected'); @@ -125,7 +123,7 @@ export default { if (data.heaters.available_heaters.length) { data.heaters.available_heaters.forEach(function(heater) { - Vue.prototype.$socket.sendObj('post_printer_subscriptions', { [heater]: [] }); + Vue.prototype.$socket.sendObj('post_printer_objects_subscription', { [heater]: [] }); }) } diff --git a/src/store/getters.js b/src/store/getters.js index e1b44de5..a7d2d5dd 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -98,7 +98,7 @@ export default { }, current_file_size: state => { - let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file); + let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename); if (file.length) return file[0]['size']; @@ -106,7 +106,7 @@ export default { }, current_file_metadata: state => { - let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file); + let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename); if (file.length) return file[0]; @@ -114,7 +114,7 @@ export default { }, current_file_estimated_time: state => { - let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file); + let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename); if (file.length) return file[0]['estimated_time']; @@ -122,7 +122,7 @@ export default { }, current_file_filament_total: state => { - let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.current_file); + let file = state.files.filter((file) => file.filename === state.printer.virtual_sdcard.filename); if (file.length) return file[0]['filament_total']; @@ -134,7 +134,7 @@ export default { }, is_printing: state => { - return (state.printer.virtual_sdcard.current_file !== ""); + return (state.printer.virtual_sdcard.filename !== ""); }, getMacros: state => { @@ -247,7 +247,7 @@ export default { getTitle: state => { if (state.socket.isConnected) { if (state.printer.pause_resume.is_paused) return "Pause Print"; - else if (state.printer.virtual_sdcard.is_active) return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.virtual_sdcard.current_file; + else if (state.printer.virtual_sdcard.is_active) return (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.virtual_sdcard.filename; return state.gui.general.printername ? state.gui.general.printername : state.printer.hostname; } else return "Mainsail"; diff --git a/src/store/mutations.js b/src/store/mutations.js index 19fc5c3b..cf0c7842 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -156,7 +156,7 @@ export default { nameSplit[0] === "temperature_probe" || nameSplit[0] === "temperature_sensors" || nameSplit[0] === "filament_switch_sensor" - ) Vue.prototype.$socket.sendObj('post_printer_subscriptions', { [key]: [] }); + ) Vue.prototype.$socket.sendObj('post_printer_objects_subscription', { [key]: [] }); } }, @@ -166,7 +166,7 @@ export default { setFileList(state, data) { state.files = []; - window.console.log(data); + //window.console.log(data); let array = Object.entries(data); for (let [key, file] of array) {