Skip to content

Commit f16fd50

Browse files
authored
Merge branch 'develop' into printerUrls
2 parents fd30305 + 897e163 commit f16fd50

File tree

119 files changed

+1844
-1026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1844
-1026
lines changed

src/App.vue

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) {
180180
}
181181
182182
get progress (): number {
183-
const progress = this.$store.getters['printer/getPrintProgress'] as number
183+
const progress: number = this.$store.getters['printer/getPrintProgress']
184184
return Math.floor(progress * 100)
185185
}
186186
@@ -229,35 +229,38 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) {
229229
const primaryColor = this.primaryColor
230230
const secondaryColor = 'rgba(255, 255, 255, 0.10)'
231231
const canvas = document.createElement('canvas')
232-
const context = canvas.getContext('2d') as CanvasRenderingContext2D
233-
canvas.width = favIconSize
234-
canvas.height = favIconSize
235-
const percent = this.progress
236-
const centerX = canvas.width / 2
237-
const centerY = canvas.height / 2
238-
const lineWidth = 8
239-
const radius = favIconSize / 2 - lineWidth / 2
240-
const startAngle = 1.5 * Math.PI
241-
const endAngle = startAngle + (percent * 2 * Math.PI / 100)
242-
243-
/* Draw the initial gray circle */
244-
context.moveTo(centerX, centerY)
245-
context.beginPath()
246-
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false)
247-
context.strokeStyle = secondaryColor
248-
context.lineWidth = lineWidth
249-
context.stroke()
250-
context.closePath()
251-
252-
/* Now draw the progress circle */
253-
context.moveTo(centerX, centerY)
254-
context.beginPath()
255-
context.arc(centerX, centerY, radius, startAngle, endAngle, false)
256-
context.strokeStyle = primaryColor
257-
context.lineWidth = lineWidth
258-
context.stroke()
259-
260-
return canvas.toDataURL('image/png')
232+
const context = canvas.getContext('2d')
233+
234+
if (context) {
235+
canvas.width = favIconSize
236+
canvas.height = favIconSize
237+
const percent = this.progress
238+
const centerX = canvas.width / 2
239+
const centerY = canvas.height / 2
240+
const lineWidth = 8
241+
const radius = favIconSize / 2 - lineWidth / 2
242+
const startAngle = 1.5 * Math.PI
243+
const endAngle = startAngle + (percent * 2 * Math.PI / 100)
244+
245+
/* Draw the initial gray circle */
246+
context.moveTo(centerX, centerY)
247+
context.beginPath()
248+
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false)
249+
context.strokeStyle = secondaryColor
250+
context.lineWidth = lineWidth
251+
context.stroke()
252+
context.closePath()
253+
254+
/* Now draw the progress circle */
255+
context.moveTo(centerX, centerY)
256+
context.beginPath()
257+
context.arc(centerX, centerY, radius, startAngle, endAngle, false)
258+
context.strokeStyle = primaryColor
259+
context.lineWidth = lineWidth
260+
context.stroke()
261+
262+
return canvas.toDataURL('image/png')
263+
}
261264
}
262265
}
263266
@@ -408,7 +411,7 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) {
408411
const files = await getFilesFromDataTransfer(event.dataTransfer)
409412
410413
if (files) {
411-
const pathWithRoot = this.$store.getters['files/getCurrentPathByRoot'](root) as string || ''
414+
const pathWithRoot: string = this.$store.getters['files/getCurrentPathByRoot'](root) ?? ''
412415
const path = pathWithRoot === root
413416
? ''
414417
: pathWithRoot.substring(root.length + 1)

src/api/httpClientActions.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ export const httpClientActions = {
3636
result: {
3737
username: string,
3838
token: string,
39-
action: string,
39+
action: 'user_jwt_refresh',
4040
source: string
4141
}
4242
}>('/access/refresh_jwt', { refresh_token }, options)
4343
},
4444

45-
accessLoginPost (username: string, password: string, source = 'moonraker', options?: AxiosRequestConfig) {
45+
accessLoginPost (username: string, password: string, source: string = 'moonraker', options?: AxiosRequestConfig) {
4646
return this.post<{
4747
result: {
4848
username: string,
4949
token: string,
5050
refresh_token: string,
51-
action: string,
51+
action: 'user_logged_in',
5252
source: string
5353
}
5454
}>('/access/login', {
@@ -62,7 +62,7 @@ export const httpClientActions = {
6262
return this.post<{
6363
result: {
6464
username: string,
65-
action: string
65+
action: 'user_logged_out'
6666
}
6767
}>('access/logout', undefined, options)
6868
},
@@ -101,8 +101,8 @@ export const httpClientActions = {
101101
username: string,
102102
token: string,
103103
refresh_token: string,
104-
action: string,
105-
source: string
104+
action: 'user_created',
105+
source: 'moonraker'
106106
}
107107
}>('/access/user', {
108108
username,
@@ -114,7 +114,7 @@ export const httpClientActions = {
114114
return this.delete<{
115115
result: {
116116
username: string,
117-
action: string
117+
action: 'user_deleted'
118118
}
119119
}>('/access/user', {
120120
...options,
@@ -126,7 +126,7 @@ export const httpClientActions = {
126126
return this.post<{
127127
result: {
128128
username: string,
129-
action: string
129+
action: 'user_password_reset'
130130
}
131131
}>('/access/user/password', {
132132
password,
@@ -193,11 +193,15 @@ export const httpClientActions = {
193193
return this.postForm<{
194194
result: {
195195
item: {
196+
modified?: number,
197+
size?: number,
198+
permissions?: string,
196199
path: string,
197200
root: string
198201
}
199202
print_started?: boolean,
200-
action: string
203+
print_queued?: boolean,
204+
action: 'create_file'
201205
}
202206
}>('/server/files/upload', formData, options)
203207
},

src/components/common/BedScrewsAdjustDialog.vue

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
hide-details
2929
dense
3030
disabled
31-
:value="$t('app.general.label.partial_of_total', {partial: currentScrewIndex + 1, total: bedScrews.length})"
31+
:value="$t('app.general.label.partial_of_total', {partial: currentScrewIndex + 1, total: totalScrews})"
3232
/>
3333
</v-col>
3434
</v-row>
@@ -41,7 +41,7 @@
4141
hide-details
4242
dense
4343
disabled
44-
:value="$t('app.general.label.partial_of_total', {partial: acceptedScrews, total: bedScrews.length})"
44+
:value="$t('app.general.label.partial_of_total', {partial: acceptedScrews, total: totalScrews})"
4545
/>
4646
</v-col>
4747
</v-row>
@@ -52,7 +52,7 @@
5252
</v-row>
5353

5454
<v-progress-linear
55-
:value="acceptedScrews / bedScrews.length * 100"
55+
:value="acceptedScrews / totalScrews * 100"
5656
class="mt-2"
5757
/>
5858
</v-card-text>
@@ -98,28 +98,24 @@ import type { BedScrews } from '@/store/printer/types'
9898
9999
@Component({})
100100
export default class BedScrewsAdjustDialog extends Mixins(StateMixin, ToolheadMixin) {
101-
get bedScrews (): BedScrews[] {
102-
return this.$store.getters['printer/getBedScrews'] as BedScrews[]
103-
}
104-
105-
get bedScrewsAdjust () {
106-
return this.$store.state.printer.printer.bed_screws ?? {}
107-
}
108-
109-
get currentState () {
110-
return this.bedScrewsAdjust.state
101+
get bedScrews (): BedScrews {
102+
return this.$store.getters['printer/getBedScrews']
111103
}
112104
113105
get currentScrewIndex () {
114-
return this.bedScrewsAdjust.current_screw
106+
return this.bedScrews.current_screw ?? 0
115107
}
116108
117109
get currentScrewName () {
118-
return this.bedScrews[this.currentScrewIndex]?.prettyName
110+
return this.bedScrews.screws[this.currentScrewIndex]?.prettyName
119111
}
120112
121113
get acceptedScrews () {
122-
return this.bedScrewsAdjust.accepted_screws
114+
return this.bedScrews.accepted_screws ?? 0
115+
}
116+
117+
get totalScrews () {
118+
return this.bedScrews.screws.length
123119
}
124120
125121
get showBedScrewsAdjustDialogAutomatically (): boolean {

src/components/common/ManualProbeDialog.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,16 @@ export default class ManualProbeDialog extends Mixins(StateMixin, ToolheadMixin)
148148
].sort((a, b) => b - a)
149149
}
150150
151-
get manualProbe () {
152-
return this.$store.state.printer.printer.manual_probe
153-
}
154-
155151
get zPositionLower () {
156-
return this.manualProbe.z_position_lower?.toFixed(3)
152+
return this.$store.state.printer.printer.manual_probe?.z_position_lower?.toFixed(3)
157153
}
158154
159155
get zPosition () {
160-
return this.manualProbe.z_position?.toFixed(3)
156+
return this.$store.state.printer.printer.manual_probe?.z_position?.toFixed(3)
161157
}
162158
163159
get zPositionUpper () {
164-
return this.manualProbe.z_position_upper?.toFixed(3)
160+
return this.$store.state.printer.printer.manual_probe?.z_position_upper?.toFixed(3)
165161
}
166162
167163
get showManualProbeDialogAutomatically (): boolean {

src/components/common/ScrewsTiltAdjustDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ import type { ScrewsTiltAdjust } from '@/store/printer/types'
7878
@Component({})
7979
export default class ScrewsTiltAdjustDialog extends Mixins(StateMixin, ToolheadMixin) {
8080
get screwsTiltAdjust (): ScrewsTiltAdjust {
81-
return this.$store.getters['printer/getScrewsTiltAdjust'] as ScrewsTiltAdjust
81+
return this.$store.getters['printer/getScrewsTiltAdjust']
8282
}
8383
8484
get showScrewsTiltAdjustDialogAutomatically (): boolean {

src/components/common/SystemCommands.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,30 +142,30 @@ import type { ServerInfo, ServiceInfo, SystemInfo } from '@/store/server/types'
142142
@Component({})
143143
export default class SystemCommands extends Mixins(StateMixin, ServicesMixin) {
144144
get serverInfo (): ServerInfo {
145-
return this.$store.getters['server/getInfo'] as ServerInfo
145+
return this.$store.state.server.info
146146
}
147147
148148
get hosted (): boolean {
149149
return this.$store.state.config.hostConfig.hosted
150150
}
151151
152152
get powerDevices (): Device[] {
153-
return this.$store.getters['power/getDevices'] as Device[]
153+
return this.$store.getters['power/getDevices']
154154
}
155155
156156
get devicePowerComponentEnabled (): boolean {
157-
return this.$store.getters['server/componentSupport']('power') as boolean
157+
return this.$store.getters['server/componentSupport']('power')
158158
}
159159
160160
get services (): ServiceInfo[] {
161-
const services = this.$store.getters['server/getServices'] as ServiceInfo[]
161+
const services: ServiceInfo[] = this.$store.getters['server/getServices']
162162
163163
return services
164164
.filter(service => service.name !== 'klipper_mcu')
165165
}
166166
167167
get systemInfo (): SystemInfo | null {
168-
return this.$store.getters['server/getSystemInfo'] as SystemInfo | null
168+
return this.$store.state.server.system_info
169169
}
170170
171171
get canControlHost (): boolean {

src/components/layout/AppBar.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ import ServicesMixin from '@/mixins/services'
182182
import FilesMixin from '@/mixins/files'
183183
import BrowserMixin from '@/mixins/browser'
184184
import { SocketActions } from '@/api/socketActions'
185-
import type { OutputPin } from '@/store/printer/types'
185+
import type { KlipperPrinterConfig, OutputPin } from '@/store/printer/types'
186186
import type { Device } from '@/store/power/types'
187187
import { encodeGcodeParamValue } from '@/util/gcode-helpers'
188188
@@ -212,11 +212,11 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
212212
}
213213
214214
get saveConfigPending (): boolean {
215-
return this.$store.getters['printer/getSaveConfigPending'] as boolean
215+
return this.$store.getters['printer/getSaveConfigPending']
216216
}
217217
218-
get saveConfigPendingItems (): Record<string, Record<string, string>> {
219-
return this.$store.getters['printer/getSaveConfigPendingItems'] as Record<string, Record<string, string>>
218+
get saveConfigPendingItems (): KlipperPrinterConfig {
219+
return this.$store.getters['printer/getSaveConfigPendingItems']
220220
}
221221
222222
get showSaveConfigAndRestartForPendingChanges (): boolean {
@@ -263,7 +263,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
263263
264264
switch (type) {
265265
case 'klipper': {
266-
const device = this.$store.getters['printer/getPinByName'](name) as OutputPin | undefined
266+
const device: OutputPin | undefined = this.$store.getters['printer/getPinByName'](name)
267267
268268
if (!device) return null
269269
@@ -275,7 +275,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
275275
}
276276
277277
default: {
278-
const device = this.$store.getters['power/getDeviceByName'](topNavPowerToggle) as Device | undefined
278+
const device: Device | undefined = this.$store.getters['power/getDeviceByName'](topNavPowerToggle)
279279
280280
if (!device) return null
281281

src/components/layout/AppToolsDrawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default class AppToolsDrawer extends Mixins(StateMixin) {
4545
}
4646
4747
get serverInfo () {
48-
return this.$store.getters['server/getInfo']
48+
return this.$store.state.server.info
4949
}
5050
5151
get hasUpdates (): boolean {

src/components/layout/AppUploadAndPrintBtn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default class AppUploadAndPrintBtn extends Vue {
4141
readonly uploadFile!: HTMLInputElement
4242
4343
get rootProperties (): RootProperties {
44-
return this.$store.getters['files/getRootProperties']('gcodes') as RootProperties
44+
return this.$store.getters['files/getRootProperties']('gcodes')
4545
}
4646
4747
get accepts () {

src/components/layout/AppUserMenu.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@
8686
<script lang="ts">
8787
import { Component, Vue } from 'vue-property-decorator'
8888
import { startCase, capitalize } from 'lodash-es'
89+
import type { AppUser } from '@/store/auth/types'
8990
9091
@Component({})
9192
export default class AppNotificationMenu extends Vue {
92-
get user () {
93-
return this.$store.getters['auth/getCurrentUser']
93+
get user (): AppUser | null {
94+
return this.$store.state.auth.currentUser
9495
}
9596
9697
get currentUser () {

src/components/settings/GeneralSettings.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
399399
}
400400
401401
get printerPowerDevicesList () {
402-
const devices = this.$store.getters['power/getDevices'] as Device[]
402+
const devices: Device[] = this.$store.getters['power/getDevices']
403403
404404
const deviceEntries = devices.map(device => ({
405405
text: `${this.$filters.prettyCase(device.device)} (${device.type})`,
@@ -432,7 +432,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
432432
}
433433
434434
get topNavPowerToggleDevicesList () {
435-
const devices = this.$store.getters['power/getDevices'] as Device[]
435+
const devices: Device[] = this.$store.getters['power/getDevices']
436436
const deviceEntries = devices.length
437437
? [
438438
{ header: 'Moonraker' },
@@ -443,7 +443,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
443443
]
444444
: []
445445
446-
const pins = this.$store.getters['printer/getPins'] as OutputPin[]
446+
const pins: OutputPin[] = this.$store.getters['printer/getPins']
447447
const pinEntries = pins.length
448448
? [
449449
{ header: 'Klipper' },

0 commit comments

Comments
 (0)