Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support opening Gcode files in Gcode Preview with drag&drop #1202

Closed
MarSoft opened this issue Oct 4, 2023 · 1 comment · Fixed by #1204
Closed

Support opening Gcode files in Gcode Preview with drag&drop #1202

MarSoft opened this issue Oct 4, 2023 · 1 comment · Fixed by #1204
Labels
FR - Enhancement New feature or request
Milestone

Comments

@MarSoft
Copy link

MarSoft commented Oct 4, 2023

Is your feature request related to a problem? Please describe

The File Manager component supports drag&drop feature. It can be used to move files around or to enqueue a file by dragging it to Job Queue block.
But if I drag the file to Gcode Preview window, nothing happens.
It would be nice to be able to drag the file over Gcode Preivew and preview it right away.

Also, I'd like to be able to drag the file to some external website, for example Pretty Gcode which can also be embedded as a "camera", and have this file opened on the site. For it to work, we should include a file's URL with the drag event.

Describe the solution you'd like

For the first part, I'm not sure how is it to better implement.
For the 2nd part, we would add the code here:

const filteredSelectedItems = this.selected
.filter(item => (item.name !== '..'))
const draggedItems = filteredSelectedItems.length > 0
? filteredSelectedItems
: [item]
this.ghost = document.createElement('div')
this.ghost.classList.add('bulk-drag')
this.ghost.classList.add((this.$vuetify.theme.dark) ? 'theme--dark' : 'theme--light')
this.ghost.innerHTML = this.$tc('app.file_system.tooltip.move_item', draggedItems.length)
document.body.appendChild(this.ghost)
e.dataTransfer.dropEffect = 'move'
e.dataTransfer.setDragImage(this.ghost, 0, 0)
const source = draggedItems
this.$emit('drag-start', source, e.dataTransfer)

with a call to e.dataTransfer.setData('text', full_url_to_the_file). I've checked and file can be downloaded by its full URL; such URL looks something like http://MOONRAKER_IP_OR_DOMAIN:PORT/server/files/gcodes/FILEPATH. Not sure what would be the best way to generate such URL.

Describe alternatives you've considered

No response

Additional information

The PrettyGcode should also be updated to accept HTTP links as input files in addition to local files, but it would be easy as soon as we attach the actual URL in the event, instead of just storing current object in a private variable.

@pedrolamas
Copy link
Member

This has now been implemented from Fluidd's side, so that you can drag a job (or any other file) from the file browser window and it will supply the drop target with a download link to the dragged file.

@pedrolamas pedrolamas added this to the 1.26 milestone Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR - Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants