Skip to content

Commit

Permalink
fix: cannot upload GCODE files on iOS (#1152)
Browse files Browse the repository at this point in the history
fix #1117
  • Loading branch information
meteyou authored Nov 14, 2022
1 parent c9ab078 commit 2aa181c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/components/TheTopbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<input
ref="fileUploadAndStart"
type="file"
:accept="validGcodeExtensions.join(', ')"
:accept="gcodeInputFileAccept.join(', ')"
style="display: none"
@change="uploadAndStart" />
<v-btn
Expand Down Expand Up @@ -174,6 +174,12 @@ export default class TheTopbar extends Mixins(BaseMixin) {
fileUploadAndStart: HTMLFormElement
}
get gcodeInputFileAccept() {
if (this.isIOS) return []
return validGcodeExtensions
}
get naviDrawer() {
return this.$store.state.naviDrawer
}
Expand All @@ -182,10 +188,6 @@ export default class TheTopbar extends Mixins(BaseMixin) {
this.$store.dispatch('setNaviDrawer', newVal)
}
get validGcodeExtensions() {
return validGcodeExtensions
}
get currentPage() {
return this.$route.fullPath
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/mixins/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ export default class BaseMixin extends Vue {
return 'ontouchstart' in window || (navigator.maxTouchPoints > 0 && navigator.maxTouchPoints !== 256)
}

get isIOS() {
return !!(
navigator.userAgent.match(/(iPad|iPhone|iPod)/) ||
// @ts-ignore
(navigator.platform === 'MacIntel' && typeof navigator.standalone !== 'undefined')
)
}

get moonrakerComponents() {
return this.$store.state.server?.components ?? []
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/panels/GcodefilesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<input
ref="fileUpload"
type="file"
:accept="validGcodeExtensions.join(', ')"
:accept="gcodeInputFileAccept.join(', ')"
style="display: none"
multiple
@change="uploadFile" />
Expand Down Expand Up @@ -585,7 +585,6 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
mdiCheckboxMarked = mdiCheckboxMarked
mdiDragVertical = mdiDragVertical
validGcodeExtensions = validGcodeExtensions
formatFilesize = formatFilesize
formatPrintTime = formatPrintTime
sortFiles = sortFiles
Expand Down Expand Up @@ -668,6 +667,12 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
return this.files.findIndex((file) => file.filename === name) >= 0
}
get gcodeInputFileAccept() {
if (this.isIOS) return []
return validGcodeExtensions
}
get currentPath() {
const path = this.$store.state.gui.view.gcodefiles.currentPath
if (path === 'gcodes') return ''
Expand Down

0 comments on commit 2aa181c

Please sign in to comment.