diff --git a/src/App.vue b/src/App.vue index ebac3cedc8..51512f8041 100644 --- a/src/App.vue +++ b/src/App.vue @@ -180,7 +180,7 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) { } get progress (): number { - const progress = this.$store.getters['printer/getPrintProgress'] as number + const progress: number = this.$store.getters['printer/getPrintProgress'] return Math.floor(progress * 100) } @@ -229,35 +229,38 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) { const primaryColor = this.primaryColor const secondaryColor = 'rgba(255, 255, 255, 0.10)' const canvas = document.createElement('canvas') - const context = canvas.getContext('2d') as CanvasRenderingContext2D - canvas.width = favIconSize - canvas.height = favIconSize - const percent = this.progress - const centerX = canvas.width / 2 - const centerY = canvas.height / 2 - const lineWidth = 8 - const radius = favIconSize / 2 - lineWidth / 2 - const startAngle = 1.5 * Math.PI - const endAngle = startAngle + (percent * 2 * Math.PI / 100) - - /* Draw the initial gray circle */ - context.moveTo(centerX, centerY) - context.beginPath() - context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false) - context.strokeStyle = secondaryColor - context.lineWidth = lineWidth - context.stroke() - context.closePath() - - /* Now draw the progress circle */ - context.moveTo(centerX, centerY) - context.beginPath() - context.arc(centerX, centerY, radius, startAngle, endAngle, false) - context.strokeStyle = primaryColor - context.lineWidth = lineWidth - context.stroke() - - return canvas.toDataURL('image/png') + const context = canvas.getContext('2d') + + if (context) { + canvas.width = favIconSize + canvas.height = favIconSize + const percent = this.progress + const centerX = canvas.width / 2 + const centerY = canvas.height / 2 + const lineWidth = 8 + const radius = favIconSize / 2 - lineWidth / 2 + const startAngle = 1.5 * Math.PI + const endAngle = startAngle + (percent * 2 * Math.PI / 100) + + /* Draw the initial gray circle */ + context.moveTo(centerX, centerY) + context.beginPath() + context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false) + context.strokeStyle = secondaryColor + context.lineWidth = lineWidth + context.stroke() + context.closePath() + + /* Now draw the progress circle */ + context.moveTo(centerX, centerY) + context.beginPath() + context.arc(centerX, centerY, radius, startAngle, endAngle, false) + context.strokeStyle = primaryColor + context.lineWidth = lineWidth + context.stroke() + + return canvas.toDataURL('image/png') + } } } @@ -408,7 +411,7 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) { const files = await getFilesFromDataTransfer(event.dataTransfer) if (files) { - const pathWithRoot = this.$store.getters['files/getCurrentPathByRoot'](root) as string || '' + const pathWithRoot: string = this.$store.getters['files/getCurrentPathByRoot'](root) ?? '' const path = pathWithRoot === root ? '' : pathWithRoot.substring(root.length + 1) diff --git a/src/api/httpClientActions.ts b/src/api/httpClientActions.ts index 67067066e2..dd17f4546b 100644 --- a/src/api/httpClientActions.ts +++ b/src/api/httpClientActions.ts @@ -36,19 +36,19 @@ export const httpClientActions = { result: { username: string, token: string, - action: string, + action: 'user_jwt_refresh', source: string } }>('/access/refresh_jwt', { refresh_token }, options) }, - accessLoginPost (username: string, password: string, source = 'moonraker', options?: AxiosRequestConfig) { + accessLoginPost (username: string, password: string, source: string = 'moonraker', options?: AxiosRequestConfig) { return this.post<{ result: { username: string, token: string, refresh_token: string, - action: string, + action: 'user_logged_in', source: string } }>('/access/login', { @@ -62,7 +62,7 @@ export const httpClientActions = { return this.post<{ result: { username: string, - action: string + action: 'user_logged_out' } }>('access/logout', undefined, options) }, @@ -101,8 +101,8 @@ export const httpClientActions = { username: string, token: string, refresh_token: string, - action: string, - source: string + action: 'user_created', + source: 'moonraker' } }>('/access/user', { username, @@ -114,7 +114,7 @@ export const httpClientActions = { return this.delete<{ result: { username: string, - action: string + action: 'user_deleted' } }>('/access/user', { ...options, @@ -126,7 +126,7 @@ export const httpClientActions = { return this.post<{ result: { username: string, - action: string + action: 'user_password_reset' } }>('/access/user/password', { password, @@ -193,11 +193,15 @@ export const httpClientActions = { return this.postForm<{ result: { item: { + modified?: number, + size?: number, + permissions?: string, path: string, root: string } print_started?: boolean, - action: string + print_queued?: boolean, + action: 'create_file' } }>('/server/files/upload', formData, options) }, diff --git a/src/components/common/BedScrewsAdjustDialog.vue b/src/components/common/BedScrewsAdjustDialog.vue index d856171af6..c9a02ac8ee 100644 --- a/src/components/common/BedScrewsAdjustDialog.vue +++ b/src/components/common/BedScrewsAdjustDialog.vue @@ -28,7 +28,7 @@ hide-details dense disabled - :value="$t('app.general.label.partial_of_total', {partial: currentScrewIndex + 1, total: bedScrews.length})" + :value="$t('app.general.label.partial_of_total', {partial: currentScrewIndex + 1, total: totalScrews})" /> @@ -41,7 +41,7 @@ hide-details dense disabled - :value="$t('app.general.label.partial_of_total', {partial: acceptedScrews, total: bedScrews.length})" + :value="$t('app.general.label.partial_of_total', {partial: acceptedScrews, total: totalScrews})" /> @@ -52,7 +52,7 @@ @@ -98,28 +98,24 @@ import type { BedScrews } from '@/store/printer/types' @Component({}) export default class BedScrewsAdjustDialog extends Mixins(StateMixin, ToolheadMixin) { - get bedScrews (): BedScrews[] { - return this.$store.getters['printer/getBedScrews'] as BedScrews[] - } - - get bedScrewsAdjust () { - return this.$store.state.printer.printer.bed_screws ?? {} - } - - get currentState () { - return this.bedScrewsAdjust.state + get bedScrews (): BedScrews { + return this.$store.getters['printer/getBedScrews'] } get currentScrewIndex () { - return this.bedScrewsAdjust.current_screw + return this.bedScrews.current_screw ?? 0 } get currentScrewName () { - return this.bedScrews[this.currentScrewIndex]?.prettyName + return this.bedScrews.screws[this.currentScrewIndex]?.prettyName } get acceptedScrews () { - return this.bedScrewsAdjust.accepted_screws + return this.bedScrews.accepted_screws ?? 0 + } + + get totalScrews () { + return this.bedScrews.screws.length } get showBedScrewsAdjustDialogAutomatically (): boolean { diff --git a/src/components/common/ManualProbeDialog.vue b/src/components/common/ManualProbeDialog.vue index d2d8bc06ab..31544c035e 100644 --- a/src/components/common/ManualProbeDialog.vue +++ b/src/components/common/ManualProbeDialog.vue @@ -148,20 +148,16 @@ export default class ManualProbeDialog extends Mixins(StateMixin, ToolheadMixin) ].sort((a, b) => b - a) } - get manualProbe () { - return this.$store.state.printer.printer.manual_probe - } - get zPositionLower () { - return this.manualProbe.z_position_lower?.toFixed(3) + return this.$store.state.printer.printer.manual_probe?.z_position_lower?.toFixed(3) } get zPosition () { - return this.manualProbe.z_position?.toFixed(3) + return this.$store.state.printer.printer.manual_probe?.z_position?.toFixed(3) } get zPositionUpper () { - return this.manualProbe.z_position_upper?.toFixed(3) + return this.$store.state.printer.printer.manual_probe?.z_position_upper?.toFixed(3) } get showManualProbeDialogAutomatically (): boolean { diff --git a/src/components/common/ScrewsTiltAdjustDialog.vue b/src/components/common/ScrewsTiltAdjustDialog.vue index c81940cf81..6e7adc70d6 100644 --- a/src/components/common/ScrewsTiltAdjustDialog.vue +++ b/src/components/common/ScrewsTiltAdjustDialog.vue @@ -78,7 +78,7 @@ import type { ScrewsTiltAdjust } from '@/store/printer/types' @Component({}) export default class ScrewsTiltAdjustDialog extends Mixins(StateMixin, ToolheadMixin) { get screwsTiltAdjust (): ScrewsTiltAdjust { - return this.$store.getters['printer/getScrewsTiltAdjust'] as ScrewsTiltAdjust + return this.$store.getters['printer/getScrewsTiltAdjust'] } get showScrewsTiltAdjustDialogAutomatically (): boolean { diff --git a/src/components/common/SystemCommands.vue b/src/components/common/SystemCommands.vue index 984a1107e4..2528f58b37 100644 --- a/src/components/common/SystemCommands.vue +++ b/src/components/common/SystemCommands.vue @@ -142,7 +142,7 @@ import type { ServerInfo, ServiceInfo, SystemInfo } from '@/store/server/types' @Component({}) export default class SystemCommands extends Mixins(StateMixin, ServicesMixin) { get serverInfo (): ServerInfo { - return this.$store.getters['server/getInfo'] as ServerInfo + return this.$store.state.server.info } get hosted (): boolean { @@ -150,22 +150,22 @@ export default class SystemCommands extends Mixins(StateMixin, ServicesMixin) { } get powerDevices (): Device[] { - return this.$store.getters['power/getDevices'] as Device[] + return this.$store.getters['power/getDevices'] } get devicePowerComponentEnabled (): boolean { - return this.$store.getters['server/componentSupport']('power') as boolean + return this.$store.getters['server/componentSupport']('power') } get services (): ServiceInfo[] { - const services = this.$store.getters['server/getServices'] as ServiceInfo[] + const services: ServiceInfo[] = this.$store.getters['server/getServices'] return services .filter(service => service.name !== 'klipper_mcu') } get systemInfo (): SystemInfo | null { - return this.$store.getters['server/getSystemInfo'] as SystemInfo | null + return this.$store.state.server.system_info } get canControlHost (): boolean { diff --git a/src/components/layout/AppBar.vue b/src/components/layout/AppBar.vue index 819e126eea..170b81e11a 100644 --- a/src/components/layout/AppBar.vue +++ b/src/components/layout/AppBar.vue @@ -182,7 +182,7 @@ import ServicesMixin from '@/mixins/services' import FilesMixin from '@/mixins/files' import BrowserMixin from '@/mixins/browser' import { SocketActions } from '@/api/socketActions' -import type { OutputPin } from '@/store/printer/types' +import type { KlipperPrinterConfig, OutputPin } from '@/store/printer/types' import type { Device } from '@/store/power/types' import { encodeGcodeParamValue } from '@/util/gcode-helpers' @@ -212,11 +212,11 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin } get saveConfigPending (): boolean { - return this.$store.getters['printer/getSaveConfigPending'] as boolean + return this.$store.getters['printer/getSaveConfigPending'] } - get saveConfigPendingItems (): Record> { - return this.$store.getters['printer/getSaveConfigPendingItems'] as Record> + get saveConfigPendingItems (): KlipperPrinterConfig { + return this.$store.getters['printer/getSaveConfigPendingItems'] } get showSaveConfigAndRestartForPendingChanges (): boolean { @@ -263,7 +263,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin switch (type) { case 'klipper': { - const device = this.$store.getters['printer/getPinByName'](name) as OutputPin | undefined + const device: OutputPin | undefined = this.$store.getters['printer/getPinByName'](name) if (!device) return null @@ -275,7 +275,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin } default: { - const device = this.$store.getters['power/getDeviceByName'](topNavPowerToggle) as Device | undefined + const device: Device | undefined = this.$store.getters['power/getDeviceByName'](topNavPowerToggle) if (!device) return null diff --git a/src/components/layout/AppToolsDrawer.vue b/src/components/layout/AppToolsDrawer.vue index 8ad62ce7b8..de720c99c5 100644 --- a/src/components/layout/AppToolsDrawer.vue +++ b/src/components/layout/AppToolsDrawer.vue @@ -45,7 +45,7 @@ export default class AppToolsDrawer extends Mixins(StateMixin) { } get serverInfo () { - return this.$store.getters['server/getInfo'] + return this.$store.state.server.info } get hasUpdates (): boolean { diff --git a/src/components/layout/AppUploadAndPrintBtn.vue b/src/components/layout/AppUploadAndPrintBtn.vue index 001478a780..ce32ce66c4 100644 --- a/src/components/layout/AppUploadAndPrintBtn.vue +++ b/src/components/layout/AppUploadAndPrintBtn.vue @@ -41,7 +41,7 @@ export default class AppUploadAndPrintBtn extends Vue { readonly uploadFile!: HTMLInputElement get rootProperties (): RootProperties { - return this.$store.getters['files/getRootProperties']('gcodes') as RootProperties + return this.$store.getters['files/getRootProperties']('gcodes') } get accepts () { diff --git a/src/components/layout/AppUserMenu.vue b/src/components/layout/AppUserMenu.vue index 0119fb7494..b3cc74cee3 100644 --- a/src/components/layout/AppUserMenu.vue +++ b/src/components/layout/AppUserMenu.vue @@ -86,11 +86,12 @@ diff --git a/src/components/widgets/spoolman/QRReader.vue b/src/components/widgets/spoolman/QRReader.vue index e5a01b9339..567b2f62cc 100644 --- a/src/components/widgets/spoolman/QRReader.vue +++ b/src/components/widgets/spoolman/QRReader.vue @@ -124,8 +124,8 @@ export default class QRReader extends Mixins(StateMixin, BrowserMixin) { this.processing = false } - get availableSpools () { - return this.$store.getters['spoolman/getAvailableSpools'] + get availableSpools (): Spool[] { + return this.$store.state.spoolman.availableSpools } handleCodeFound (code: string) { diff --git a/src/components/widgets/spoolman/SpoolSelectionDialog.vue b/src/components/widgets/spoolman/SpoolSelectionDialog.vue index ac788c7d86..c1a8fe58a0 100644 --- a/src/components/widgets/spoolman/SpoolSelectionDialog.vue +++ b/src/components/widgets/spoolman/SpoolSelectionDialog.vue @@ -210,6 +210,7 @@ import QrScanner from 'qr-scanner' import type { AppTableHeader } from '@/types' import getFilePaths from '@/util/get-file-paths' import type { DataTableHeader } from 'vuetify' +import type { KlipperPrinterConfig } from '@/store/printer/types' @Component({ components: { @@ -318,7 +319,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi }, ] - const mergedTableHeaders = this.$store.getters['config/getMergedTableHeaders'](headers, 'spoolman') as AppTableHeader[] + const mergedTableHeaders: AppTableHeader[] = this.$store.getters['config/getMergedTableHeaders'](headers, 'spoolman') return mergedTableHeaders } @@ -355,7 +356,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi } get currentFileName () { - return this.filename || this.$store.state.printer.printer.print_stats.filename + return this.filename || this.$store.state.printer.printer.print_stats?.filename || '' } get currentFile () { @@ -368,7 +369,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi } get enabledWebcams (): WebcamConfig[] { - return this.$store.getters['webcams/getEnabledWebcams'] as WebcamConfig[] + return this.$store.getters['webcams/getEnabledWebcams'] } get availableCameras (): Pick[] { @@ -429,7 +430,8 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi `SET_GCODE_VARIABLE MACRO=${this.targetMacro} VARIABLE=spool_id VALUE=${this.selectedSpool ?? 'None'}` ] - const supportsSaveVariables = this.$store.getters['printer/getPrinterConfig']('save_variables') + const printerConfig: KlipperPrinterConfig = this.$store.getters['printer/getPrinterConfig'] + const supportsSaveVariables = printerConfig.save_variables if (supportsSaveVariables) { // persist selected spool across restarts commands.push(`SAVE_VARIABLE VARIABLE=${this.targetMacro.toLowerCase()}__spool_id VALUE=${this.selectedSpool ?? 'None'}`) diff --git a/src/components/widgets/spoolman/SpoolmanCard.vue b/src/components/widgets/spoolman/SpoolmanCard.vue index 482998fb53..08dd5229b9 100644 --- a/src/components/widgets/spoolman/SpoolmanCard.vue +++ b/src/components/widgets/spoolman/SpoolmanCard.vue @@ -206,7 +206,7 @@ export default class SpoolmanCard extends Mixins(StateMixin) { }) } - get selectedCardFields (): string[] { + get selectedCardFields (): string[][] { const fields = this.$store.state.config.uiSettings.spoolman.selectedCardFields const columnCount = fields.length > 1 ? 2 : 1 const elementsPerColumn = Math.ceil(fields.length / columnCount) @@ -219,11 +219,11 @@ export default class SpoolmanCard extends Mixins(StateMixin) { } get isConnected (): boolean { - return this.$store.getters['spoolman/getConnected'] + return this.$store.state.spoolman.connected } get targetableMacros (): MacroWithSpoolId[] { - const macros = this.$store.getters['macros/getMacros'] as Macro[] + const macros: Macro[] = this.$store.getters['macros/getMacros'] return macros .filter((macro): macro is MacroWithSpoolId => macro.variables != null && 'spool_id' in macro.variables) diff --git a/src/components/widgets/stats/PrinterStatsCard.vue b/src/components/widgets/stats/PrinterStatsCard.vue index 3d9b79aade..a84a31154f 100644 --- a/src/components/widgets/stats/PrinterStatsCard.vue +++ b/src/components/widgets/stats/PrinterStatsCard.vue @@ -134,6 +134,7 @@ diff --git a/src/components/widgets/system/McuCard.vue b/src/components/widgets/system/McuCard.vue index 9112ce7267..6203e0446a 100644 --- a/src/components/widgets/system/McuCard.vue +++ b/src/components/widgets/system/McuCard.vue @@ -80,11 +80,11 @@ export default class PrinterStatsCard extends Vue { readonly mcu!: MCU get klippyApp (): KlippyApp { - return this.$store.getters['printer/getKlippyApp'] as KlippyApp + return this.$store.getters['printer/getKlippyApp'] } - get mcuConstants () { - return this.mcu.mcu_constants || {} as Record + get mcuConstants (): Record { + return this.mcu.mcu_constants || {} } mcuInformationDialogOpen = false diff --git a/src/components/widgets/system/SystemOverviewCard.vue b/src/components/widgets/system/SystemOverviewCard.vue index 806f700000..6cfb1a06f9 100644 --- a/src/components/widgets/system/SystemOverviewCard.vue +++ b/src/components/widgets/system/SystemOverviewCard.vue @@ -126,7 +126,7 @@ export default class PrinterStatsCard extends Vue { peripheralsDialogOpen = false get systemInfo (): SystemInfo | null { - return this.$store.getters['server/getSystemInfo'] + return this.$store.state.server.system_info } get cpuInfo () { @@ -174,7 +174,7 @@ export default class PrinterStatsCard extends Vue { } get canRolloverLogs (): boolean { - return this.$store.getters['server/getIsMinApiVersion']('1.0.5') as boolean + return this.$store.getters['server/getIsMinApiVersion']('1.0.5') } } diff --git a/src/components/widgets/system/SystemUsageCard.vue b/src/components/widgets/system/SystemUsageCard.vue index 2991ff8f3a..67ffd95139 100644 --- a/src/components/widgets/system/SystemUsageCard.vue +++ b/src/components/widgets/system/SystemUsageCard.vue @@ -9,9 +9,7 @@ -