diff --git a/src/components/widgets/system/SystemOverviewCard.vue b/src/components/widgets/system/SystemOverviewCard.vue index d43861d026..741660fe23 100644 --- a/src/components/widgets/system/SystemOverviewCard.vue +++ b/src/components/widgets/system/SystemOverviewCard.vue @@ -124,6 +124,7 @@ import { Component, Mixins } from 'vue-property-decorator' import type { SystemInfo, CpuInfo, DistroInfo, Virtualization } from '@/store/server/types' import StateMixin from '@/mixins/state' +import type { PrinterInfo } from '@/store/printer/types' @Component({}) export default class PrinterStatsCard extends Mixins(StateMixin) { @@ -174,8 +175,8 @@ export default class PrinterStatsCard extends Mixins(StateMixin) { .join(', ') } - get printerInfo () { - return this.$store.state.printer.printer.info + get printerInfo (): PrinterInfo { + return this.$store.state.printer.info } get canRolloverLogs (): boolean { diff --git a/src/store/printer/actions.ts b/src/store/printer/actions.ts index d42434c684..765c3b4bf6 100644 --- a/src/store/printer/actions.ts +++ b/src/store/printer/actions.ts @@ -22,7 +22,7 @@ export const actions: ActionTree = { }, async checkKlipperMinVersion ({ state, dispatch }) { - const klipperVersion = state.printer.info.software_version ?? '?' + const klipperVersion = state.info.software_version ?? '?' const fullKlipperVersion = klipperVersion.includes('-') ? klipperVersion diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index 4cc1eca1c4..5348763cce 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -49,25 +49,19 @@ export const getters: GetterTree = { // If an external source fires an estop, or the client // is refreshed while klipper is down - the webhook data maybe invalid // but the printer info should be good. - if ( - state.printer.info.state_message && - state.printer.info.state_message !== '' - ) { - return state.printer.info.state_message.trim().replace(/\r\n|\r|\n/g, '
') + if (state.info.state_message) { + return state.info.state_message.trim().replace(/\r\n|\r|\n/g, '
') } - if ( - state.printer.webhooks.state_message && - state.printer.webhooks.state_message !== '' - ) { + if (state.printer.webhooks.state_message) { return state.printer.webhooks.state_message.trim().replace(/\r\n|\r|\n/g, '
') } return 'Unknown' }, getKlippyApp: (state) => { - const app = state.printer.info.app?.toLowerCase() + const app = state.info.app?.toLowerCase() - const klippyApp = isKeyOf(app, Globals.SUPPORTED_SERVICES.klipper) + const klippyApp = app && isKeyOf(app, Globals.SUPPORTED_SERVICES.klipper) ? app : 'klipper' diff --git a/src/store/printer/mutations.ts b/src/store/printer/mutations.ts index b396d985e1..bb0f91cd2d 100644 --- a/src/store/printer/mutations.ts +++ b/src/store/printer/mutations.ts @@ -14,17 +14,13 @@ export const mutations: MutationTree = { }, setPrinterInfo (state, payload) { - Vue.set(state.printer, 'info', payload) + state.info = payload }, setQueryEndstops (state, payload) { state.printer.endstops = payload }, - setPrinterBusy (state, payload: boolean) { - state.printer.busy = payload - }, - setPrinterObjectList (state, payload) { if (!state.printer.objects.includes(payload)) { state.printer.objects.push(payload) diff --git a/src/store/printer/state.ts b/src/store/printer/state.ts index 935ba2da46..1465550314 100644 --- a/src/store/printer/state.ts +++ b/src/store/printer/state.ts @@ -6,6 +6,10 @@ import type { PrinterState } from './types' */ export const defaultState = (): PrinterState => { return { + info: { + state: '', + state_message: '' + }, printer: { endstops: {}, bed_mesh: { @@ -15,10 +19,6 @@ export const defaultState = (): PrinterState => { available_heaters: [], available_sensors: [] }, - info: { - state: '', - state_message: '' - }, configfile: { warnings: [], save_config_pending: false, diff --git a/src/store/printer/types.ts b/src/store/printer/types.ts index eec10b93af..5c66adb7b1 100644 --- a/src/store/printer/types.ts +++ b/src/store/printer/types.ts @@ -1,9 +1,22 @@ export interface PrinterState { - printer: Printer; + info: PrinterInfo; + printer: Record; } -export interface Printer { - [key: string]: any; +export interface PrinterInfo { + state: string; + state_message: string; + hostname?: string; + klipper_path?: string; + python_path?: string; + process_id?: number; + user_id?: number; + group_id?: number; + log_file?: string; + config_file?: string; + software_version?: string; + cpu_info?: string + app?: string; } export interface KnownExtruder {