Skip to content

Commit b4c8d1d

Browse files
committed
feat: console command history
1 parent 8776fbc commit b4c8d1d

5 files changed

Lines changed: 106 additions & 28 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<template>
2+
<div>
3+
<v-text-field
4+
:value="newValue"
5+
@input="emitChange"
6+
:items="history"
7+
class="ma-4"
8+
clearable
9+
solo
10+
dense
11+
hide-details
12+
placeholder="Send gcode"
13+
append-outer-icon="mdi-send"
14+
@click:append-outer="emitSend(newValue)"
15+
@keyup.enter="emitSend(newValue)"
16+
@keyup.up="historyUp()"
17+
@keyup.down="historyDown()">
18+
</v-text-field>
19+
<!-- {{ originalHistory}}<br />
20+
{{ history }} -->
21+
</div>
22+
</template>
23+
24+
<script lang="ts">
25+
import { Vue, Component, Prop } from 'vue-property-decorator'
26+
27+
@Component({})
28+
export default class InputConsoleCommand extends Vue {
29+
@Prop({ type: String, required: true })
30+
public value!: string
31+
32+
newValue = ''
33+
history: string[] = []
34+
originalHistory: string[] = []
35+
isFirst = true
36+
37+
mounted () {
38+
this.newValue = this.value
39+
}
40+
41+
emitChange (val: string) {
42+
this.newValue = val
43+
this.$emit('input', val)
44+
}
45+
46+
emitSend (val: string) {
47+
if (val && val.length > 0) {
48+
this.newValue = ''
49+
if (this.history.length >= 5) {
50+
this.originalHistory.shift()
51+
}
52+
this.originalHistory.unshift(val)
53+
this.history = Object.assign([], this.originalHistory)
54+
this.isFirst = true
55+
this.$emit('send', val)
56+
}
57+
}
58+
59+
historyUp () {
60+
if (this.history.length >= 1) {
61+
if (!this.isFirst) {
62+
const f = this.history.shift() as string
63+
this.history.push(f)
64+
}
65+
this.newValue = this.history[0]
66+
this.isFirst = false
67+
}
68+
}
69+
70+
historyDown () {
71+
if (this.history.length >= 1) {
72+
if (!this.isFirst) {
73+
const f = this.history.pop() as string
74+
this.history.unshift(f)
75+
}
76+
this.newValue = this.history[0]
77+
this.isFirst = false
78+
}
79+
}
80+
}
81+
</script>

src/components/widgets/ConsoleWidget.vue

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
<v-card outlined color="#1c1c1c" class="console-container mb-3 pa-1" height="300">
44
<span v-for="(item, index) in consoleItems" :key="index" v-html="item"></span>
55
</v-card>
6-
<v-text-field
6+
<input-console-command
7+
v-model="consoleCommand"
8+
@send="sendCommand"
9+
>
10+
</input-console-command>
11+
<!-- <v-text-field
712
v-model="consoleCommand"
813
:items="consoleHistory"
914
class="ma-4"
@@ -14,7 +19,8 @@
1419
placeholder="Send gcode"
1520
append-outer-icon="mdi-send"
1621
@click:append-outer="sendCommand(consoleCommand)"
17-
@keyup.enter="sendCommand(consoleCommand)"></v-text-field>
22+
@keyup.enter="sendCommand(consoleCommand)">
23+
</v-text-field> -->
1824
<!-- <v-virtual-scroll
1925
:bench="50"
2026
:items="consoleItems"
@@ -33,24 +39,22 @@
3339
<script lang="ts">
3440
import { Component, Mixins } from 'vue-property-decorator'
3541
import UtilsMixin from '@/mixins/utils'
42+
import InputConsoleCommand from '@/components/inputs/inputConsoleCommand.vue'
3643
37-
@Component({})
44+
@Component({
45+
components: {
46+
InputConsoleCommand
47+
}
48+
})
3849
export default class ConsoleWidget extends Mixins(UtilsMixin) {
3950
get consoleItems () {
4051
return this.$store.state.socket.console
4152
}
4253
4354
consoleCommand = ''
44-
consoleHistory: string[] = []
4555
46-
sendCommand (command: string) {
47-
// keep a history of 5 items.
56+
sendCommand (command?: string) {
4857
if (command && command.length) {
49-
this.consoleCommand = ''
50-
if (this.consoleHistory.length >= 5) {
51-
this.consoleHistory.shift()
52-
}
53-
this.consoleHistory.unshift(command)
5458
this.sendGcode(command)
5559
}
5660
}

src/components/widgets/TemperatureTargetsWidget.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,5 @@ export default class TemperatureTargetsWidget extends Mixins(UtilsMixin) {
122122
setFanTargetTemp (item: Fan, target: number) {
123123
this.sendGcode(`SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=${item.name} TARGET=${target}`)
124124
}
125-
126-
mounted () {
127-
// setTimeout(() => {}, 3000)
128-
}
129125
}
130126
</script>
131-
132-
<style type="scss" scoped>
133-
134-
</style>

src/store/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const configureChartEntry = (key: string, val: {[key: string]: number },
7474
if ('target' in val) {
7575
r.target.y = val.target
7676
} else {
77-
r.target.y = state.printer[key].target // this could be undefined, but i don't think the chart cares?
77+
r.target.y = state.printer[key].target || 0 // sensors may not have targets
7878
}
7979

8080
return r

todo.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# TODO [fluidd]
22

33
## Next Up
4-
- Config file list / editing
4+
- add min and max for sensors and probes
55
- move to mdi svg icons, and reduce overall size
6-
- dynamic favicon that looks like the percent finished ring
7-
- impl quick print button
86
- expand current print metadata (with bigger thumb?)
7+
- file / folder move
8+
- allow theme change dark / light
9+
- dynamic favicon that looks like the percent finished ring
10+
- firmware restart from config page
11+
- have config page visible on klippy disconnect (socket connect vs klippy connect)
912

1013
## Known Bugs:
1114
- multi line gcodes not having a Send: prefix after the first line
@@ -14,14 +17,12 @@
1417
- the metadata load fails because the file is no longer there.
1518

1619
## General Improvements
17-
- draggable dashboard panels
18-
- allow contraction and expansion of dashboard panels
19-
- implement new console history
20+
- draggable dashboard panels?
21+
- allow contraction and expansion of dashboard panels?
2022
- add console.log wrapper for dev vs prod
21-
- add a throttle to temp updates, print timers, position trackers.
23+
- add a throttle to (socket notifications) temp updates, print timers, position trackers.
2224
- Performance / memory heap checks
2325
- add status of heater_fans (extruder fan and controller fan)
24-
- allow theme change dark / light
2526
- stick git version in the footer somewhere for klipper, moonraker and fluidd
2627
- filter out temp waits from console
2728
- cancel and pause really need a confirm dialog

0 commit comments

Comments
 (0)