Skip to content

Commit

Permalink
fix: ensure logs card isn't shown when client / klippy is in error.
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Dec 30, 2020
1 parent 4e4edd3 commit 004ebe0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
29 changes: 1 addition & 28 deletions src/components/cards/KlippyDisconnectedCard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<collapsable-card
v-if="showCard"
v-if="printerWarnings.length && !klippyConnected"
:title="'Klippy: ' + klippyState"
:collapsable="false"
icon="$alert">
Expand Down Expand Up @@ -47,37 +47,10 @@ import { Globals } from '@/globals'
components: {}
})
export default class KlippyDisconnectedCard extends Mixins(UtilsMixin) {
get showCard () {
return (!this.klippyConnected || this.clientWarnings.length)
}
get socketReady () {
return this.$store.state.socket.ready
}
// Return a list of warnings we deem necessary for
// correct usage of the web client.
get clientWarnings () {
const config = this.$store.state.socket.printer.configfile.config
const warnings = []
if (config && !config.virtual_sdcard) {
warnings.push({ message: '[virtual_sdcard] not found in printer configuration.' })
}
if (config && !config.pause_resume) {
warnings.push({ message: '[pause_resume] not found in printer configuration.' })
}
if (config && !config.display_status) {
warnings.push({ message: '[display_status] not found in printer configuration.' })
}
if (config && ('gcode_macro CANCEL_PRINT' in config === false)) {
warnings.push({ message: 'CANCEL_PRINT macro not found in configuration.' })
}
return warnings
}
get appName () {
return Globals.APP_NAME
}
Expand Down
23 changes: 23 additions & 0 deletions src/mixins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ export default class UtilsMixin extends Vue {
return false
}

// Return a list of warnings we deem necessary for
// correct usage of the web client.
get printerWarnings () {
const config = this.$store.state.socket.printer.configfile.config
const warnings = []
if (config && !config.virtual_sdcard) {
warnings.push({ message: '[virtual_sdcard] not found in printer configuration.' })
}

if (config && !config.pause_resume) {
warnings.push({ message: '[pause_resume] not found in printer configuration.' })
}

if (config && !config.display_status) {
warnings.push({ message: '[display_status] not found in printer configuration.' })
}

if (config && ('gcode_macro CANCEL_PRINT' in config === false)) {
warnings.push({ message: 'CANCEL_PRINT macro not found in configuration.' })
}
return warnings
}

get xyHomed (): boolean {
return this.$store.getters['socket/getHomedAxes']('xy')
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<klippy-disconnected-card></klippy-disconnected-card>
<bed-mesh-card v-if="supportsBedMesh && klippyConnected"></bed-mesh-card>
<v-row>
<v-col cols="12" sm="6" class="pt-0">
<v-col cols="12" sm="6" class="pt-0" v-if="!printerWarnings.length && klippyConnected">
<logs-card></logs-card>
</v-col>
<v-col cols="12" sm="6" class="pt-0" v-if="klippyConnected">
Expand Down
2 changes: 1 addition & 1 deletion src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<v-container fluid class="constrained-width px-2 px-sm-4">
<v-row class="mt-0 mt-sm-2">
<v-col cols="12" md="6" class="pt-0">
<klippy-disconnected-card v-if="!klippyConnected"></klippy-disconnected-card>
<klippy-disconnected-card></klippy-disconnected-card>
<status-card v-if="klippyConnected"></status-card>
<draggable
class="list-group"
Expand Down

0 comments on commit 004ebe0

Please sign in to comment.