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

Luci-app-filemanager #7300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rdmitry0911
Copy link

@rdmitry0911 rdmitry0911 commented Oct 2, 2024

  • This PR is not from my main or master branch πŸ’©, but a separate branch βœ…
  • Each commit has a valid βœ’οΈ Signed-off-by: <[email protected]> row (via git commit --signoff) βœ…
  • Each commit and PR title has a valid πŸ“ <package name>: title first line subject for packages βœ…
  • Incremented πŸ†™ any PKG_VERSION in the Makefile βœ…
  • Tested on: (architecture, openwrt version, browser) βœ…
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
  • ( Optional ) Closes: e.g. openwrt/luci#issue-number
  • ( Optional ) Depends on: e.g. openwrt/packages#pr-number in sister repo
  • Description: (describe the changes proposed in this PR) Full featured File Manager for LUCI. Easy navigation thru directory structure and selected files editing. Effectively replaces nano + openssh-sftp-server
Screenshot 2024-10-02 at 2 31 22 PM Screenshot 2024-10-02 at 2 31 49 PM

@rdmitry0911
Copy link
Author

New version includes:

  • Navigation with resizable window/columns and with list sorting
  • Directory and files creation/renaming/removing
  • Directory and files attributes changing
  • Large files uploading/downloading
  • Large files editing
  • Storage of Interface settings in config file
    Screenshot 2024-10-15 at 8 21 57 AM
    Screenshot 2024-10-15 at 8 22 57 AM
    Screenshot 2024-10-15 at 8 23 12 AM
    Screenshot 2024-10-15 at 8 23 50 AM
    Screenshot 2024-10-15 at 8 25 15 AM
    Screenshot 2024-10-15 at 8 27 10 AM
    Screenshot 2024-10-15 at 8 27 30 AM

@systemcrash
Copy link
Contributor

Looking good. Avoid merge commits. Just rebase your work on master.

@rdmitry0911
Copy link
Author

Looking good. Avoid merge commits. Just rebase your work on master.

This way is better?

Copy link
Contributor

@dannil dannil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the contribution guidelines; squash both your commits together and name it something like luci-app-filemanager: add app and put further verbose explanation into the commit body instead of the subject. And just do a rebase, right now you've included every commit again which (I guess) was newer than your HEAD.

@systemcrash
Copy link
Contributor

Amend your commit subject

@rdmitry0911
Copy link
Author

Amend your commit subject

What would you propose?

@systemcrash
Copy link
Contributor

OK great. I think this is ready. @dannil @stokito @feckert any opinions?

@stokito
Copy link
Contributor

stokito commented Oct 23, 2024

It solves user problems, won't affect existing functionality so let's merge. There are some styling issues, but that can be improved gradually latter. This is a first time contribution for @rdmitry0911 so I don't want to overwhelm him with minor comments but rather send a PR myself.
Users need for some solution today and this can help a lot for them.

@systemcrash
Copy link
Contributor

Do you want to take it for a test-drive @stokito ?

@stokito
Copy link
Contributor

stokito commented Oct 23, 2024

I tested and it works. My main comments are:
0. Not sure if we need options for styling like width/height, padding etc.

  1. Rename Current Directory: to a Starting Folder:
  2. Use Luci's own uci.js to get options.
  3. Use Luci's own fs to get list of files instead of calling of ls

In general this may be confusing for users with existing plugin filebrowser. Maybe it worth to call it luci-app-filebrowser-extended or something like that. But instead I hope that one day we can merge the luci-app-filebrowser into Luci itself once it become more mature.

@systemcrash
Copy link
Contributor

@rdmitry0911 please address @stokito's comments.

@stokito
Copy link
Contributor

stokito commented Oct 23, 2024

They aren't critical and we may work out them later. The app works and can be merged

@rdmitry0911
Copy link
Author

I tested and it works. My main comments are: 0. Not sure if we need options for styling like width/height, padding etc.

Initially there were no settings for width/height and padding, but finally I added them as different users have different environments and it is convenient to start this app with width/height, padding you like rather then adjust them right next to start.

1. Rename `Current Directory:` to a `Starting Folder:`

No problem, I'll do that. Should I change a version number just for this commit or it is better to collect several changes and commit them together for version changing?

2. Use Luci's own uci.js to get options.

3. Use Luci's own fs to get list of files instead of calling of `ls`

In fact initially it was done that way, however, using ls, cat and the likes makes the code more compact. And as far as those utils are required for running any system, using them is harmless.

@systemcrash
Copy link
Contributor

I would prefer to use the built-in fs lib than suffering monstrous regexp to process ls output. fs has a bunch of stable and usable properties. Then you avoid risks associated with parsing of dates, times and permissions.

@rdmitry0911
Copy link
Author

I would prefer to use the built-in fs lib than suffering monstrous regexp to process ls output. fs has a bunch of stable and usable properties. Then you avoid risks associated with parsing of dates, times and permissions.

The problem of using 'fs.list()' is that I can't find a way to get information about symbolic links. They are returned as directories. I have to use 'fs.stat()' for every directory in a list to find links. It produces significant overhead in comparison with 'ls'

@stokito
Copy link
Contributor

stokito commented Oct 25, 2024

That's true, the /var/ is a symlink but is returned as:

          {
            "type": "directory",
            "inode": 1,
            "ctime": 1729862220,
            "atime": 1729222217,
            "uid": 0,
            "mtime": 1729862220,
            "gid": 0,
            "mode": 17407,
            "name": "var",
            "size": 820
          },

The /bin/ash is a file symlink but this also not represnted:

          {
            "type": "file",
            "inode": 35494,
            "ctime": 1708105277,
            "atime": 1729222218,
            "uid": 0,
            "mtime": 1708088432,
            "gid": 0,
            "mode": 33261,
            "name": "ash",
            "size": 524309
          },

We'll need to add fix this in the RPCD itself.

The fs.js says that the symlink will be in the type:

 * @typedef {Object} FileStatEntry
 * @property {string} type - Type of the entry, one of `block`, `char`, `directory`, `fifo`, `symlink`, `file`, `socket` or `unknown`

We better not to change the type but instead introduce a separate property for symlinks. Maybe we need to support the hardlinks too, not sure.
@systemcrash maybe you can create a feature request for this?

@rdmitry0911
Copy link
Author

We better not to change the type but instead introduce a separate property for symlinks. Maybe we need to support the hardlinks too, not sure.

I would also return a target of a symlink in a separated property to avoid extra fs.stat()

@stokito
Copy link
Contributor

stokito commented Oct 25, 2024

Makes sense. Also eventually we'll need to add a button to create a symlink.
@rdmitry0911 please let us know if you'll add anything to the pr or it can be merged. I hope everybody here are fine to merge the app. Once it merged it may attract more contributors

@rdmitry0911
Copy link
Author

Makes sense. Also eventually we'll need to add a button to create a symlink. @rdmitry0911 please let us know if you'll add anything to the pr or it can be merged. I hope everybody here are fine to merge the app. Once it merged it may attract more contributors

I think you can merge it.

@systemcrash
Copy link
Contributor

@stokito
Copy link
Contributor

stokito commented Oct 25, 2024

we better to fix the rpcd in the first place than use a workaround with ucode

@systemcrash
Copy link
Contributor

Ah yeah - it doesn't exist in the lib yet. Worth it to add it.

@systemcrash
Copy link
Contributor

@jow- in da house. Can we get a linkstat lstat function in rpcd please?

@rdmitry0911
Copy link
Author

Is there anything I can do to accelerate approvals for this PR?

@systemcrash
Copy link
Contributor

OK, I have a suitable patch for rpcd, which may take a while to get added. But here's how it works:

root@OpenWrt:/# ubus call file lstat '{"path":"/etc/os-release"}'
{
	"path": "/etc/os-release",
	"type": "symlink",
	"size": 21,
	"mode": 41471,
	"atime": 1727094886,
	"mtime": 1727094886,
	"ctime": 1727094886,
	"inode": 219,
	"uid": 0,
	"gid": 0
}
root@OpenWrt:/# ubus call file stat '{"path":"/etc/os-release"}'
{
	"path": "/etc/os-release",
	"type": "file",
	"size": 528,
	"mode": 33188,
	"atime": 1727094886,
	"mtime": 1727094886,
	"ctime": 1727094886,
	"inode": 1124,
	"uid": 0,
	"gid": 0
}
root@OpenWrt:/# ubus call file stat '{"path":"/var"}'
{
	"path": "/var",
	"type": "directory",
	"size": 520,
	"mode": 17407,
	"atime": 1730221560,
	"mtime": 1730221753,
	"ctime": 1730221753,
	"inode": 1,
	"uid": 0,
	"gid": 0
}
root@OpenWrt:/# ubus call file lstat '{"path":"/var"}'
{
	"path": "/var",
	"type": "symlink",
	"size": 3,
	"mode": 41471,
	"atime": 1727094886,
	"mtime": 1727094886,
	"ctime": 1727094886,
	"inode": 1264,
	"uid": 0,
	"gid": 0
}
root@OpenWrt:/# ubus call file stat '{"path":"/bin/ash"}'
{
	"path": "/bin/ash",
	"type": "file",
	"size": 405522,
	"mode": 33261,
	"atime": 1727094886,
	"mtime": 1727094886,
	"ctime": 1727094886,
	"inode": 15,
	"uid": 0,
	"gid": 0
}
root@OpenWrt:/# ubus call file lstat '{"path":"/bin/ash"}'
{
	"path": "/bin/ash",
	"type": "symlink",
	"size": 7,
	"mode": 41471,
	"atime": 1727094886,
	"mtime": 1727094886,
	"ctime": 1727094886,
	"inode": 13,
	"uid": 0,
	"gid": 0
}

@rdmitry0911
Copy link
Author

Also, an "Invert Selection" button for multiple selections would be great.
Use case: select files to keep, invert, delete.

Last feature?

Don't quite understand the functionality. Just invert selection? Or need extra options?

Also, an "Invert Selection" button for multiple selections would be great.
Use case: select files to keep, invert, delete.

Last feature?

Implemented with alt-click

@systemcrash
Copy link
Contributor

So invert selection looks good, but there's no visual indicator of its availability. Users would have to know about it already and be informed about 'click alt'. Adding a button 'Invert Selection' once a selection is made is a good signal - you can keep the alt behaviour around, though. That's good once you know it ;)

@rdmitry0911
Copy link
Author

So invert selection looks good, but there's no visual indicator of its availability. Users would have to know about it already and be informed about 'click alt'. Adding a button 'Invert Selection' once a selection is made is a good signal - you can keep the alt behaviour around, though. That's good once you know it ;)

I'm going to implement a help tab with all the explanations. The less items we have in the interface the more easy it will be to maintain.

@rdmitry0911
Copy link
Author

New update with help tab and HEX editor/viewer

@rdmitry0911
Copy link
Author

changes

Don't quite understand what to do

@systemcrash
Copy link
Contributor

Don't quite understand the functionality. Just invert selection? Or need extra options?

Just an invert selection button which arises once a selection has been made - then it's intuitive. But you're not keen on having one...

@rdmitry0911
Copy link
Author

Don't quite understand the functionality. Just invert selection? Or need extra options?

Just an invert selection button which arises once a selection has been made - then it's intuitive. But you're not keen on having one...

Yea, I left that for a future contributors if there are any :)

@rdmitry0911
Copy link
Author

Added ASCII, HEX and RegExp search to hex editor

@rdmitry0911
Copy link
Author

Changed comments to English ones

@systemcrash
Copy link
Contributor

OK - no more new features as my review time is finite, and this thing could grow forever.

@rdmitry0911
Copy link
Author

OK - no more new features as my review time is finite, and this thing could grow forever.

Ok. No more new features :)

- Navigation in resizable window
- Scrollable and sortable list of files with name, type, creation date/time columns
- Directory and files creation/renaming/removing
- Directory and files attributes changing
- Duplicating any object in the current directory
- Selecting objects individually and everything for removing selected
- Inverting selection with alt-click
- Large files uploading/downloading
- Drag'n'Drop multiple files from local directory to server
- Large files editing
- Line numbers toggle in editing window
- HEX mode for editing/viewing
- ASCII, HEX and RegExp search in HEX mode
- Storage of interface settings in config file
- Help tab with a short manual

Signed-off-by: Dmitry R <[email protected]>
@rdmitry0911
Copy link
Author

changes

What should I do with this request? I don't quite understand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants