From 3051c9a033ce2a846f80875943df8d6b0deb43ab Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 9 Mar 2020 00:46:36 +0100 Subject: [PATCH] add control-buttons to dashboard. add temperature_fans to heaters, add restart buttons, reconnect api --- src/App.vue | 14 ++- src/components/panels/ControlPanel.vue | 109 +++++++++++++++++++++++ src/components/panels/StatusPanel.vue | 6 +- src/components/panels/TempchartPanel.vue | 9 +- src/components/panels/ToolsPanel.vue | 25 +++++- src/components/panels/index.js | 2 + src/inputs/ToolInput.vue | 4 +- src/main.js | 5 +- src/pages/Dashboard.vue | 9 +- src/store/index.js | 103 +++++++++++++++++++-- src/store/variables.js | 4 +- 11 files changed, 263 insertions(+), 27 deletions(-) create mode 100644 src/components/panels/ControlPanel.vue diff --git a/src/App.vue b/src/App.vue index 9b99f4a84..740141dfa 100644 --- a/src/App.vue +++ b/src/App.vue @@ -46,6 +46,15 @@ + + + + Connecting to Klipper + + + + + {{ version }} © 2019 @@ -76,10 +85,10 @@ export default { this.$socket.sendObj('get_printer_objects', {}, 'getObjectInfo'); this.$socket.sendObj('get_printer_status', { heater: [] }, 'getObjectInfo'); this.$socket.sendObj('post_printer_subscriptions', { - gcode: ["gcode_position", "speed", "speed_factor", "extrude_factor", "busy", "abs_extrude"], + gcode: [], toolhead: [], virtual_sdcard: [], - header: [], + heater: [], heater_bed: [], extruder: ["temperature", "target"], fan: [], @@ -100,6 +109,7 @@ export default { version: state => state.printer.version, loadingEmergencyStop: state => state.socket.loadingEmergencyStop, isConnected: state => state.socket.isConnected, + isConnecting: state => !state.socket.isConnected, }), }, methods: { diff --git a/src/components/panels/ControlPanel.vue b/src/components/panels/ControlPanel.vue new file mode 100644 index 000000000..e75490b6b --- /dev/null +++ b/src/components/panels/ControlPanel.vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 28ee04ac6..0fa46dae8 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -35,8 +35,8 @@ - - + + Printstatus @@ -59,7 +59,7 @@ - + fa-thermometer-three-quarters Temperature Chart - {{ heatersCount }} heaters + + {{ heatersCount }} heaters + , {{ temperature_fans.length }} fan + , {{ temperature_fans.length }} fans + @@ -37,7 +41,8 @@ datasets: state => state.temperaturChart.datasets, }), ...mapGetters([ - 'heatersCount' + 'heatersCount', + 'temperature_fans' ]) }, methods: { diff --git a/src/components/panels/ToolsPanel.vue b/src/components/panels/ToolsPanel.vue index fed9c6721..66c7e8e24 100644 --- a/src/components/panels/ToolsPanel.vue +++ b/src/components/panels/ToolsPanel.vue @@ -10,7 +10,11 @@ fa-thermometer-three-quarters Heaters - {{ heatersCount }} heaters + + {{ heatersCount }} heaters + , {{ temperature_fans.length }} fan + , {{ temperature_fans.length }} fans + @@ -29,7 +33,20 @@ {{ heater.temperature.toFixed(1) }}°C - + + + + +
+ + + + {{ fan.name }}
+ {{ fan.target > 0 && fan.speed > 0 ? (fan.speed * 100).toFixed(0)+"%" : (fan.target > 0 ? "standby" : "off") }} +
+ {{ fan.temperature.toFixed(1) }}°C + +
@@ -41,7 +58,6 @@ import { mapGetters } from 'vuex' import toolInput from '../../inputs/ToolInput' - export default { components: { toolInput @@ -54,7 +70,8 @@ computed: { ...mapGetters([ 'heaters', - 'heatersCount' + 'heatersCount', + 'temperature_fans' ]) }, methods: { diff --git a/src/components/panels/index.js b/src/components/panels/index.js index 429bbe83b..676e3aa80 100644 --- a/src/components/panels/index.js +++ b/src/components/panels/index.js @@ -3,10 +3,12 @@ import Vue from 'vue' import StatusPanel from './StatusPanel.vue' import ToolsPanel from './ToolsPanel.vue' import TempchartPanel from './TempchartPanel.vue' +import ControlPanel from "./ControlPanel"; Vue.component('status-panel', StatusPanel); Vue.component('tools-panel', ToolsPanel); Vue.component('tempchart-panel', TempchartPanel); +Vue.component('control-panel', ControlPanel); export default { StatusPanel, diff --git a/src/inputs/ToolInput.vue b/src/inputs/ToolInput.vue index 021e596d1..2d6bfabf0 100644 --- a/src/inputs/ToolInput.vue +++ b/src/inputs/ToolInput.vue @@ -25,13 +25,15 @@ props: { name: String, target: Number, + command: String, + attributeName: String, }, computed: { }, methods: { setTemps() { - this.$socket.sendObj('post_printer_gcode', {script: 'SET_HEATER_TEMPERATURE HEATER='+this.name+' TARGET='+this.value}); + this.$socket.sendObj('post_printer_gcode', {script: this.command+' '+this.attributeName+'='+this.name+' TARGET='+this.value}); } }, watch: { diff --git a/src/main.js b/src/main.js index 29ef1c25e..b8692a3e0 100644 --- a/src/main.js +++ b/src/main.js @@ -10,7 +10,10 @@ import { hostname } from './store/variables' import 'vue-toast-notification/dist/index.css'; Vue.use(JRPCWS, 'ws://' + hostname + '/websocket', { - store: store + store: store, + reconnectEnabled: true, + reconnectInterval: 3000, + recconectAttempts: 1000, }); Vue.config.productionTip = false; diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index 0f1e7c414..c99acc58e 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -1,12 +1,11 @@