Merge remote-tracking branch 'meteyou/master' into feature/gcodeviewer

This commit is contained in:
Juan Rosario committed 2021-08-06 13:58:29 -05:00
commit 9437da4444
8 files changed
+151 -71

No files matched your search

@@ -1,9 +1,5 @@
<style scoped lang="scss">
.consoleTable.mini {
max-height: 300px;
overflow-y: auto;
overflow-x: hidden;
}
</style>
<template>
@@ -29,7 +25,7 @@
import Component from "vue-class-component";
import Vue from "vue";
import {Prop} from "vue-property-decorator";
import ConsoleTableEntry from "@/components/ConsoleTableEntry.vue";
import ConsoleTableEntry from "@/components/console/ConsoleTableEntry.vue";
@Component({
components: {ConsoleTableEntry}
})
+46 -15
View File
@@ -6,13 +6,13 @@
</style>
<template>
<v-card v-if="socketIsConnected" class="mb-9">
<v-toolbar flat dense>
<v-card v-if="socketIsConnected" class="mb-6 d-flex flex-column">
<v-toolbar flat dense class="order-0">
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-console-line</v-icon>{{ $t("Panels.MiniconsolePanel.Headline") }}</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text>
<v-card-text :class="consoleDirection === 'table' ? 'order-1' : 'order-2'">
<v-row>
<v-col>
<v-textarea
@@ -41,7 +41,7 @@
<command-help-modal @onCommand="gcode = $event" ></command-help-modal>
<v-menu :offset-y="true" :close-on-content-click="false" :title="$t('Panels.MiniconsolePanel.SetupConsole')">
<template v-slot:activator="{ on, attrs }">
<v-btn class="px-2 minwidth-0" color="grey darken-3 ml-3" v-bind="attrs" v-on="on"><v-icon>mdi-cog</v-icon></v-btn>
<v-btn class="px-2 minwidth-0" color="grey darken-3 ml-3" v-bind="attrs" v-on="on"><v-icon>mdi-filter</v-icon></v-btn>
</template>
<v-list>
<v-list-item class="minHeight36">
@@ -55,14 +55,17 @@
</v-col>
</v-row>
</v-card-text>
<v-card-text class="pa-0">
<v-card-text :class="(consoleDirection === 'table' ? 'order-2' : 'order-1') + ' pa-0'">
<v-row>
<v-col class="pb-0">
<console-table ref="console"
:events="events"
:is-mini="true"
@command-click="commandClick"
/>
<v-col>
<perfect-scrollbar ref="miniConsoleScroll" :class="'d-flex flex-column '+(consoleDirection === 'shell' ? 'justify-end' : '')" :style="'height: '+consoleHeight+'px;'">
<console-table ref="console"
:events="events"
:is-mini="true"
@command-click="commandClick"
/>
<v-divider></v-divider>
</perfect-scrollbar>
</v-col>
</v-row>
</v-card-text>
@@ -71,11 +74,12 @@
<script lang="ts">
import { strLongestEqual, reverseString} from "@/plugins/helpers"
import { Component, Mixins } from 'vue-property-decorator'
import {Component, Mixins, Watch} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import {CommandHelp, VTextareaType} from "@/store/printer/types";
import ConsoleTable from "@/components/ConsoleTable.vue";
import ConsoleTable from "@/components/console/ConsoleTable.vue";
import CommandHelpModal from "@/components/CommandHelpModal.vue";
import Vue from "vue";
@Component({
components: {
@@ -86,7 +90,8 @@ import CommandHelpModal from "@/components/CommandHelpModal.vue";
export default class MiniconsolePanel extends Mixins(BaseMixin) {
$refs!: {
gcodeCommandField: VTextareaType,
console: ConsoleTable
console: ConsoleTable,
miniConsoleScroll: any
}
private gcode = ""
@@ -99,8 +104,21 @@ export default class MiniconsolePanel extends Mixins(BaseMixin) {
return this.$store.state.printer.helplist ?? []
}
get consoleDirection() {
return this.$store.state.gui.console.direction ?? 'table'
}
get consoleHeight() {
return this.$store.state.gui.console.height ?? 300
}
get events() {
return this.$store.getters["server/getConsoleEvents"].slice(0, 250)
return this.$store.getters["server/getConsoleEvents"](this.consoleDirection === 'table', 250)
}
@Watch('events')
eventsChanged() {
if (this.consoleDirection === 'shell') this.scrollToBottom()
}
get hideWaitTemperatures(): boolean {
@@ -208,5 +226,18 @@ export default class MiniconsolePanel extends Mixins(BaseMixin) {
toggleFilter(filter: string) {
this.$store.dispatch('gui/updateConsoleFilter', filter)
}
mounted() {
if (this.consoleDirection === 'shell') this.scrollToBottom()
}
scrollToBottom() {
this.$nextTick(() => {
if (this.$refs.miniConsoleScroll) {
const perfectScroll = ((this.$refs.miniConsoleScroll as Vue).$el as HTMLDivElement)
perfectScroll.scrollTop = perfectScroll.scrollHeight
}
})
}
}
</script>
+49 -7
View File
@@ -6,8 +6,12 @@
<div>
<v-card flat v-if="!form.bool">
<v-card-text>
<settings-row :title="$t('Settings.ConsoleTab.ShowOnDashboard')" :dynamic-slot-width="true">
<v-switch v-model="boolShowOnDashboard" hide-details class="mt-0"></v-switch>
<settings-row :title="$t('Settings.ConsoleTab.Direction')">
<v-select v-model="consoleDirection" :items="availableDirections" hide-details outlined dense></v-select>
</settings-row>
<v-divider class="my-2"></v-divider>
<settings-row :title="$t('Settings.ConsoleTab.Height')">
<v-slider v-model="consoleHeightTmp" @change="updateConsoleHeight" hide-details :min="200" :max="900" :step="10" :label="consoleHeightTmp+'px'" ></v-slider>
</settings-row>
<v-divider class="my-2"></v-divider>
<settings-row :title="$t('Settings.ConsoleTab.HideTemperatures')" :dynamic-slot-width="true">
@@ -71,9 +75,10 @@
<script lang="ts">
import {Component, Mixins} from "vue-property-decorator";
import {Component, Mixins, Watch} from "vue-property-decorator";
import BaseMixin from "../mixins/base";
import SettingsRow from "@/components/settings/SettingsRow.vue";
import {Debounce} from "vue-debounce-decorator";
interface consoleForm {
bool: boolean
@@ -100,16 +105,53 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) {
unique: (value: string) => !this.existsPresetName(value) || 'Name already exists',
}
private consoleHeightTmp = 300
mounted() {
this.consoleHeightTmp = this.consoleHeight
}
get consoleFilters() {
return this.$store.getters["gui/getConsoleFilters"] ?? []
}
get boolShowOnDashboard() {
return this.$store.state.gui.console.boolDashboard
get availableDirections() {
return [
{
text: this.$t('Settings.ConsoleTab.DirectionTable'),
value: 'table'
}, {
text: this.$t('Settings.ConsoleTab.DirectionShell'),
value: 'shell'
}
]
}
set boolShowOnDashboard(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'console.boolDashboard', value: newVal })
get consoleDirection() {
return this.$store.state.gui.console.direction ?? 'table'
}
set consoleDirection(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'console.direction', value: newVal })
}
get consoleHeight() {
return this.$store.state.gui.console.height ?? 300
}
set consoleHeight(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'console.height', value: newVal })
}
@Watch('consoleHeight')
consoleHeightChanged(newVal: number) {
this.consoleHeightTmp = newVal
}
@Debounce(500)
updateConsoleHeight(newVal: number) {
window.console.log("updateConsoleHeight", newVal)
this.consoleHeight = newVal
}
get hideWaitTemperatures() {
+4 -1
View File
@@ -538,7 +538,10 @@
},
"ConsoleTab": {
"Console": "Console",
"ShowOnDashboard": "Show on dashboard",
"Direction": "Direction",
"DirectionTable": "Last entry on the top",
"DirectionShell": "Last entry at the bottom",
"Height": "Height",
"HideTemperatures": "Hide temperatures",
"CreateHeadline": "Create filter",
"Name": "Name",
+44 -39
View File
@@ -1,35 +1,14 @@
<style scoped>
.gcode-command-field {
.consoleScrollContainer {
max-height: calc(100vh - 180px);
}
.gcode-command-field .v-input__slot {
margin-bottom: 0;
}
.gcode-command-field .v-text-field__details {
display: none;
}
.gcode-command-btn {
margin-top: 5px;
}
.log-cell.title-cell {
vertical-align: top;
height: auto !important;
}
.log-cell.content-cell {
vertical-align: top;
min-height: auto;
height: auto !important;
}
</style>
<template>
<div>
<v-row>
<div class="d-flex flex-column">
<v-row :class="this.consoleDirection === 'table' ? 'order-0' : 'order-1 mt-3'">
<v-col class="col">
<v-textarea
v-model="gcode"
@@ -58,9 +37,9 @@
<command-help-modal
@onCommand="gcode = $event"
></command-help-modal>
<v-menu :offset-y="true" :close-on-content-click="false" :title="$t('Console.SetupConsole')">
<v-menu offset-y :top="consoleDirection === 'shell'" :close-on-content-click="false" :title="$t('Console.SetupConsole')">
<template v-slot:activator="{ on, attrs }">
<v-btn class="ml-3 px-2 minwidth-0" color="lightgray" v-bind="attrs" v-on="on"><v-icon>mdi-cog</v-icon></v-btn>
<v-btn class="ml-3 px-2 minwidth-0" color="lightgray" v-bind="attrs" v-on="on"><v-icon>mdi-filter</v-icon></v-btn>
</template>
<v-list>
<v-list-item class="minHeight36">
@@ -73,15 +52,17 @@
</v-menu>
</v-col>
</v-row>
<v-row>
<v-row :class="this.consoleDirection === 'table' ? 'order-1' : 'order-0 mt-0'">
<v-col xs12>
<v-card>
<v-card-text class="pa-0" style="max-height: calc(100vh - 180px); overflow: auto;">
<console-table ref="console"
:is-mini="false"
:events="events"
@command-click="commandClick"
/>
<v-card-text class="pa-0">
<perfect-scrollbar ref="consoleScroll" class="consoleScrollContainer d-flex flex-column justify-end">
<console-table ref="console"
:is-mini="false"
:events="events"
@command-click="commandClick"
/>
</perfect-scrollbar>
</v-card-text>
</v-card>
</v-col>
@@ -90,17 +71,18 @@
</template>
<script lang="ts">
import {Component, Mixins} from "vue-property-decorator";
import {Component, Mixins, Watch} from "vue-property-decorator";
import BaseMixin from "@/components/mixins/base";
import ConsoleTable from "@/components/ConsoleTable.vue";
import ConsoleTable from "@/components/console/ConsoleTable.vue";
import {CommandHelp, ConsoleCommandHelp, VTextareaType} from "@/store/printer/types";
import {reverseString, strLongestEqual} from "@/plugins/helpers";
import CommandHelpModal from "@/components/CommandHelpModal.vue";
import Vue from "vue";
@Component({
components: {
CommandHelpModal,
ConsoleTable
ConsoleTable,
}
})
export default class PageConsole extends Mixins(BaseMixin) {
@@ -111,15 +93,25 @@ export default class PageConsole extends Mixins(BaseMixin) {
$refs!: {
gcodeCommandField: VTextareaType,
console: ConsoleTable
console: ConsoleTable,
consoleScroll: any
}
get helplist(): CommandHelp[] {
return this.$store.state.printer.helplist ?? []
}
get consoleDirection() {
return this.$store.state.gui.console.direction ?? 'table'
}
get events() {
return this.$store.getters["server/getConsoleEvents"]
return this.$store.getters["server/getConsoleEvents"](this.consoleDirection === 'table')
}
@Watch('events')
eventsChanged() {
if (this.consoleDirection === 'shell') this.scrollToBottom()
}
get hideWaitTemperatures(): boolean {
@@ -225,5 +217,18 @@ export default class PageConsole extends Mixins(BaseMixin) {
toggleFilter(filter: string): void {
this.$store.dispatch('gui/updateConsoleFilter', filter)
}
mounted() {
if (this.consoleDirection === 'shell') this.scrollToBottom()
}
scrollToBottom() {
this.$nextTick(() => {
if (this.$refs.consoleScroll) {
const perfectScroll = ((this.$refs.consoleScroll as Vue).$el as HTMLDivElement)
perfectScroll.scrollTop = perfectScroll.scrollHeight
}
})
}
}
</script>
+2 -1
View File
@@ -111,7 +111,8 @@ export const getDefaultState = (): GuiState => {
},
console: {
hideWaitTemperatures: true,
boolDashboard: true,
direction: 'table',
height: 300,
customFilters: [],
},
gcodefiles: {
+4 -2
View File
@@ -4,8 +4,10 @@ import {formatFilesize} from "@/plugins/helpers";
export const getters: GetterTree<ServerState, any> = {
getConsoleEvents: (state) => {
return [...state.events].slice(-500).reverse() ?? []
getConsoleEvents: (state) => (reverse = true, limit = 500) => {
const events = [...state.events].slice(limit * -1) ?? []
return (reverse) ? events.reverse() : events
},
getConfig: (state) => (section: string, attribute: string) => {