Spoolman
Spoolman copied to clipboard
Option for manual label text with placeholders
it would be great to be able to manually set the label text using placeholders. that way you could put the info you need in the format that makes most sense to the user.
failing this, can we get an option to remove the DB id from the label or at least move it to the front so you dont have the filament details with the id in the middle ie
eSUN - Black
#1 - PLA+
would look better as
#1 - eSUN
Black - PLA+
at least in my opinion
I have been thinking of ways to make the layout more flexible, placeholders is a great idea. Will look into that!
it would also be good to have remaining weight as an available placeholder, it would be good for stuff you dont print with often and knowing how much is there easily is more important than reprinting the label
hey, have you looked at this at all? if not i might take a crack at it
I have not started this yet, so take a crack if you want :)
i have had a quick look and i dont think it will be that hard to do.
2 things im not 100% sure on yet and would value your input.
- what do you think is the best way to do formatting. use html tags for
<b>
and similar or use something like markup's**
? - other place holder systems i have used have had a way to put extra stuff inside the placeholder so that if that value is null the extra stuff wont be included either. its useful for things like labels so they just dont show at all if the value isnt there (better than using
?
). what im not sure about here is how best to tell between the placeholder part and the other text. i dont like the idea of having a list that is checked against because a) its something to keep up to date and b) it would break if the user wanted to use that word in the other text. one idea i had was to use double{{
for the place holders and then extra text can be between the braces (eg,{Spool Weight: {spool_weight}g}
) but im not sold on it.
let me know what you think
im also assuming this would replace the list of checkboxes/switches that are there now with just a text field and either a link to a list of available placeholders or a collapsed section with the list. does that sound reasonable?
ok, i had a shot at writing this up using html for bold and the double {
format and it seems to work well. it is pretty much plain JS so may need some changes to work with react/TS but the basic functionality is there. the format helpers will also need some work for things like localised units. i havnt had a chance to test it in the actual front end yet, i am just loading up the browser JS console to test it.
regex_test.txt (sorry its a plain text file, github dosnt let you upload actual code files)
once its loaded it can be called with render_label_template(test_spool, "<b>{{id}}</b>\n<b>{{material}} - {{name}}</b>\n{Spool Weight: {spool_weight}}\n{Tool temp: {extruder_temp}}\n{Bed temp: {bed_temp}}")
and will return (and print) the formatted html for the label text. notice that the test spool has no value for bed temp so that whole section is left out
at the moment if the placeholder is invalid it is treated the same as if it is valid but null. not sure if there should be either an error put in the text or some sort of error rendered elsewhere on the page. your thoughts?
ok, i have gotten this mostly working
i also took a shot at adding an option to remove the qr code to address #231 (figured since i was working on the options ui anyway)
i have realised this introduces a potential issue with html injection (didnt realise this till i was almost done) but my view is that this ui should never be accessed by anyone outside the network anyway and if they are in the network there is nothing here for them to get other than what colour filament you print with most. i will add some filters to limit the html tags that will render but it wont be perfect so i dont consider it a fix so much as making it a bit less broken
resolved by #446