Skip to content

Commit

Permalink
fix: disable respond for '//' messages
Browse files Browse the repository at this point in the history
add feature: history in console input
  • Loading branch information
meteyou committed Mar 9, 2020
1 parent 98950a2 commit 1ae7827
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
29 changes: 28 additions & 1 deletion src/pages/Console.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
solo
class="gcode-command-field"
v-on:keyup.enter="doSend"
v-on:keyup.up="onKeyUp"
v-on:keyup.down="onKeyDown"
></v-text-field>
</v-col>

Expand Down Expand Up @@ -99,7 +101,11 @@
],
options: {
}
},
lastCommands: [
],
lastCommandNumber: null
}
},
computed: {
Expand All @@ -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, '<br>');
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 = "";
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/store/variables.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//export const hostname = window.location.host;
export const hostname = "voron250.local:8080";
export const hostname = window.location.host;
//export const hostname = "voron250.local:8080";

0 comments on commit 1ae7827

Please sign in to comment.