Skip to content

Commit

Permalink
Merge branch 'develop' into printerUrls
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamas authored Feb 4, 2025
2 parents fd30305 + 897e163 commit f16fd50
Show file tree
Hide file tree
Showing 119 changed files with 1,844 additions and 1,026 deletions.
65 changes: 34 additions & 31 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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')
}
}
}
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 13 additions & 9 deletions src/api/httpClientActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -62,7 +62,7 @@ export const httpClientActions = {
return this.post<{
result: {
username: string,
action: string
action: 'user_logged_out'
}
}>('access/logout', undefined, options)
},
Expand Down Expand Up @@ -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,
Expand All @@ -114,7 +114,7 @@ export const httpClientActions = {
return this.delete<{
result: {
username: string,
action: string
action: 'user_deleted'
}
}>('/access/user', {
...options,
Expand All @@ -126,7 +126,7 @@ export const httpClientActions = {
return this.post<{
result: {
username: string,
action: string
action: 'user_password_reset'
}
}>('/access/user/password', {
password,
Expand Down Expand Up @@ -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)
},
Expand Down
28 changes: 12 additions & 16 deletions src/components/common/BedScrewsAdjustDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
/>
</v-col>
</v-row>
Expand All @@ -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})"
/>
</v-col>
</v-row>
Expand All @@ -52,7 +52,7 @@
</v-row>

<v-progress-linear
:value="acceptedScrews / bedScrews.length * 100"
:value="acceptedScrews / totalScrews * 100"
class="mt-2"
/>
</v-card-text>
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions src/components/common/ManualProbeDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ScrewsTiltAdjustDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/components/common/SystemCommands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,30 @@ 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 {
return this.$store.state.config.hostConfig.hosted
}
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 {
Expand Down
12 changes: 6 additions & 6 deletions src/components/layout/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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<string, Record<string, string>> {
return this.$store.getters['printer/getSaveConfigPendingItems'] as Record<string, Record<string, string>>
get saveConfigPendingItems (): KlipperPrinterConfig {
return this.$store.getters['printer/getSaveConfigPendingItems']
}
get showSaveConfigAndRestartForPendingChanges (): boolean {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/AppToolsDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/AppUploadAndPrintBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
5 changes: 3 additions & 2 deletions src/components/layout/AppUserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { startCase, capitalize } from 'lodash-es'
import type { AppUser } from '@/store/auth/types'
@Component({})
export default class AppNotificationMenu extends Vue {
get user () {
return this.$store.getters['auth/getCurrentUser']
get user (): AppUser | null {
return this.$store.state.auth.currentUser
}
get currentUser () {
Expand Down
6 changes: 3 additions & 3 deletions src/components/settings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
}
get printerPowerDevicesList () {
const devices = this.$store.getters['power/getDevices'] as Device[]
const devices: Device[] = this.$store.getters['power/getDevices']
const deviceEntries = devices.map(device => ({
text: `${this.$filters.prettyCase(device.device)} (${device.type})`,
Expand Down Expand Up @@ -432,7 +432,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
}
get topNavPowerToggleDevicesList () {
const devices = this.$store.getters['power/getDevices'] as Device[]
const devices: Device[] = this.$store.getters['power/getDevices']
const deviceEntries = devices.length
? [
{ header: 'Moonraker' },
Expand All @@ -443,7 +443,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
]
: []
const pins = this.$store.getters['printer/getPins'] as OutputPin[]
const pins: OutputPin[] = this.$store.getters['printer/getPins']
const pinEntries = pins.length
? [
{ header: 'Klipper' },
Expand Down
Loading

0 comments on commit f16fd50

Please sign in to comment.