thomasp85 / shinyFiles

A shiny extension for server side file access
196 stars 47 forks source link

Type in for file path #129

Closed bellma-lilly closed 4 years ago

bellma-lilly commented 4 years ago

This pull-request completes #53 I have added a new pencil button next to the directory dropdown that works similarly to the create directory button.

Volumes are specified without any preceding slashes. For example: "R Installation/doc/html"

This is implemented for File Select, Folder Select, and Save File

vnijs commented 4 years ago

Thanks @bellma-lilly. This is definitely a useful extension. What do you think about making the input box a bit wider? Or even inserting it below/above the button bar and leaving it there until the user clicks the pencil button again?

One thing I did notice is that if you enter a non existent directory name no error or messages are shown and, to the user, it seem you have gone to new empty directory.

image

Also, what would make this even more valuable would be tab-completion of the path/filename. Not sure how easy that would be to add. Link below seems interesting

https://stackoverflow.com/questions/14144970/jquery-autocomplete-path-bash-style

bellma-lilly commented 4 years ago

@vnijs These are all great ideas. I'm not sure when I will have a chance to work on it more, so I would like to get the pr included at this point, so maybe others can work on it as well.

vnijs commented 4 years ago

Understood @bellma-lilly. However, I do think that a check for directory existence is essential.

bellma-lilly commented 4 years ago

@vnijs I don't see any facility for error reporting in shinyFiles. Folder creation, for example, returns no errors, even if it fails. Similarly, if a directory gets removed right before someone selects it, there is no error reported. Although checking for existence would be great, there is no way to report back.

I think the question is, does this get added now in its currently functional but imperfect form so other people can improve on it, or does everyone have to wait until I have time to add it.

vnijs commented 4 years ago

Interesting point @bellma-lilly. I'm referring to a message that looks something like the below. Would that be feasible? BTW Under what conditions have you seen dir-creation fail?

image

bellma-lilly commented 4 years ago

@vnijs Well, I obviously overlooked this warning facility. Thanks for pointing it out; I will add the error message you suggest.

The way I tried to generate an error before was to create a directory, change to it in the interface, delete it from the command line, then create a new directory in the directory that had been deleted.

bellma-lilly commented 4 years ago

@vnijs I have added a warning message for when the path does not exist. Thanks for pointing me to the permissions error.

vnijs commented 4 years ago

Thanks for your contribution @bellma-lilly!

vnijs commented 4 years ago

@bellma-lilly I'm seeing some layout issues when using shinyFiles now. Can you replicate? If so, can you try for a fix? Thanks

image

bellma-lilly commented 4 years ago

@vnijs I cannot replicate this on chrome or safari on Mac. Does it always look like this for you? I have to admit I'm not a css expert and I struggled a little bit getting the dialogs to look right. But if you can help me reproduce, I will see what I can do.

Matthewh19 commented 4 years ago

I was wondering why when you paste a path in this way it is written such that you can't include the root: you have to delete the root from your path then paste it in. If someone is pasting in a path aren't they probably just copying it in from their folder viewer - how are they supposed to know that you have to delete the root? I guess my question is also could we make it so that the default is one way and if you really don't want to include your root there is a checkbox you can click to say so?

bellma-lilly commented 4 years ago

@Matthewh19 This is a security issue. You don't want to give access to the entire file system, so you are limited to specific roots. I have solved this issue for my workplace by naming the roots like the filesystem. For example, I have a root called "/home", which points to /home (for a linux filesystem). Can you do something similar.

This is also the first draft, and I'm sure there are improvements that can be made.

Matthewh19 commented 4 years ago

@bellma-lilly That is interesting. Thank you for responding! How would you do that on other operating systems?

bellma-lilly commented 4 years ago

@Matthewh19 What is an example of a full path you would like to paste?

Matthewh19 commented 4 years ago

@bellma-lilly On windows it would be something like C:\Users\Matth (but probably with a longer path than that. The app I am making would have to work on a mac also.

bellma-lilly commented 4 years ago

@Matthewh19 The important part is that the path match for the server. The client machine shouldn't matter (my personal machine is a mac, but my server is linux). If your server is a windows machine, I think setting the root to "C:\" or "C:\Users" should work, but I don't have a windows server to test that one.

If you are having people run shiny locally with their own machines as the server, you will need to set the roots programmatically depending on the OS.

Matthewh19 commented 4 years ago

Yes I am having people run shiny locally. I think that I am just going to be happy with how this is, since it works!