diff --git a/src/pages/Console.vue b/src/pages/Console.vue index 637e9d642..a98e51db6 100644 --- a/src/pages/Console.vue +++ b/src/pages/Console.vue @@ -34,6 +34,8 @@ solo class="gcode-command-field" v-on:keyup.enter="doSend" + v-on:keyup.up="onKeyUp" + v-on:keyup.down="onKeyDown" > @@ -99,7 +101,11 @@ ], options: { - } + }, + lastCommands: [ + + ], + lastCommandNumber: null } }, computed: { @@ -119,11 +125,32 @@ doSend() { this.loadingSendGcode = true; this.$socket.sendObj('post_printer_gcode', { script: this.gcode }, "sendGcode"); + this.lastCommands.push(this.gcode); + this.gcode = ""; + this.lastCommandNumber = null; }, formatMessage(message) { message = message.replace(/(?:\r\n|\r|\n)/g, '
'); return message; + }, + onKeyUp() { + if (this.lastCommandNumber === null && this.lastCommands.length) { + this.lastCommandNumber = this.lastCommands.length - 1; + this.gcode = this.lastCommands[this.lastCommandNumber]; + } else if (this.lastCommandNumber > 0) { + this.lastCommandNumber--; + this.gcode = this.lastCommands[this.lastCommandNumber]; + } + }, + onKeyDown() { + if (this.lastCommandNumber !== null && this.lastCommandNumber < (this.lastCommands.length - 1)) { + this.lastCommandNumber++; + this.gcode = this.lastCommands[this.lastCommandNumber]; + } else if (this.lastCommandNumber !== null && this.lastCommandNumber === (this.lastCommands.length - 1)) { + this.lastCommandNumber = null; + this.gcode = ""; + } } } } diff --git a/src/store/index.js b/src/store/index.js index e62ed3cfc..25e2ea7be 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -227,11 +227,7 @@ export default new Vuex.Store({ message: data }); - if (data.substring(0,2) === "//") { - data = data.replace("//", ""); - Vue.$toast.warning(data); - } else if (data.substring(0,2) === "!!") { - data = data.replace("!!", ""); + if (data.substring(0,2) === "!!") { Vue.$toast.error(data); } }, diff --git a/src/store/variables.js b/src/store/variables.js index 00301764b..3e8f5c1c0 100644 --- a/src/store/variables.js +++ b/src/store/variables.js @@ -1,2 +1,2 @@ -//export const hostname = window.location.host; -export const hostname = "voron250.local:8080"; \ No newline at end of file +export const hostname = window.location.host; +//export const hostname = "voron250.local:8080"; \ No newline at end of file