espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 90 forks source link

Allow multiple files to be uploaded #149

Closed d3nd3 closed 2 years ago

d3nd3 commented 2 years ago

I wanted this feature for the WebIDE storage.js plugin. Perhaps this is not the place to implement it since it might affect other file dialogs?

We could make instead that it can request multi or not multi, instead of just be multi supported always, in case it breaks the times when you strictly want solo file selection.

you can see active here https://d3nd3.github.io/EspruinoWebIDE/

gfwilliams commented 2 years ago

Wow, yes. Definitely make this only work if something is set in options passed into fileOpenDialog. This'll break a lot of stuff otherwise.

What happens for multiple files? callback just gets called multiple times?

Other thing to consider is stuff like images will want to pop up a dialog box (and also files may want to be renamed). You can't have multiple dialogs overlapping either, so were you just planning on having a second upload multiple menu item that just uploads direct?

Other thing is you could easily change the Bangle.js app loader's restore function. Right now it erases and uploads every file from a zip. Literally all you'd have to do is a new menu item that uploads files from a zip without erasing first.

gfwilliams commented 2 years ago

Looks like this will still allow multiple selection but will just fail silently if you do?

Can we just not call fileLoader.setAttribute("multiple","multiple"); if multiple files haven't been requested?

Also, please could you stick readerLoaded and setupReader inside fileOpenDialog? Since that's the only place they are needed I think?

d3nd3 commented 2 years ago

Okay, i'm just trying to clean the commits, squash them, its ugly

d3nd3 commented 2 years ago

Btw, I am not sure how to link in the EspruinoTools to the WebIDE, I think i've maybe broken the link somehow. To wrong commit?

d3nd3 commented 2 years ago

What happens for multiple files? callback just gets called multiple times?

Yes, exactly.

so were you just planning on having a second upload multiple menu item that just uploads direct?

I was thinking to use the 'Upload File' , it asks to rename for all of them, one by one the popup box appear repeatedly. Its a bit annoying perhaps, or its fine, depend which way you look at it.

Literally all you'd have to do is a new menu item that uploads files from a zip without erasing first.

This idea could be implemented also.

d3nd3 commented 2 years ago

Ok I'm done. What do you think? Btw I want to also improve some other things with the IDE like on mobile its a bit unusable, I need a way to delete all text on right hand side quickly, and fix the keyboard because it sometimes acts slow and doesnt let me delete a line completely.

d3nd3 commented 2 years ago

The prompts for Image adjusting and file renaming stack on top of each other, I have to click through them all one by one. The upload seems to occur after I confirm each one.

gfwilliams commented 2 years ago

Looks great, thanks!

Some more work on the IDE for mobile would be great. If you're on Android did you try 'hackers keyboard'? I find it works pretty well, but I guess some tweaks to make it work better with the default keyboard would be great.