mainsail-crew / mainsail

Mainsail is the popular web interface for managing and controlling 3D printers with Klipper.
https://docs.mainsail.xyz
GNU General Public License v3.0
1.71k stars 363 forks source link

feat: Direct link to specific printer via query parameter #1837

Closed 4cello closed 6 months ago

4cello commented 7 months ago

Description

Adds the ability to directly connect to a printer via an URL query parameter, e.g. my-mainsail.net/cam?printer=myprinter.

To accomplish this, added an optional field name to the printers (in browser/json mode). Whenever the SelectPrinterDialog is mounted, it checks the URL params and connects to the printer with the matching name, if any. Otherwise the selection dialog is displayed without an error.

I added the text field for the name to the SelectPrinterDialog and SettingsPrinterRemoteTab in an expandable sub-panel. There is currently no input validation, or checks for duplicate names.

If one were to implement a duplicate check, the name could instead be used in place of the ID, so a printer ID would either be a user specified string or a UUID. I don't have opinions either way.

TODO

Related Tickets & Documents

Simple implementation for #1731

Mobile & Desktop Screenshots/Recordings

mainsail-addprinter-name-2024-03-30_11-24 Peek 2024-03-30 11-31

[optional] Are there any post-deployment tasks we need to perform?

github-actions[bot] commented 7 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 4
github-actions[bot] commented 7 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 4
meteyou commented 6 months ago

just a short feedback here, i would not include this feature for moonrakerDB instances... i think this is not "useful/useable" in this case. if a user will use this, should change the config.json for example.

4cello commented 6 months ago

I assumed that would be the case. The current implementation just filters the printer list for the given name, and if there's none or multiple printers, it just shows the selection dialog (and prints the error to the console), so it should not be invasive at all.

github-actions[bot] commented 6 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 4
github-actions[bot] commented 6 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 4