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

  • 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
}

@stokito
Copy link
Contributor

stokito commented Oct 29, 2024 via email

@rdmitry0911
Copy link
Author

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

This patch resolves only lack of individual file information. Another patch for fs.list() is required to get all the information about folder contents at once like using ls -l.

@rdmitry0911
Copy link
Author

We may merge it as is and the rpcd chamge can be made later

Agree. The app just works. We can improve it later on

- 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
- Large files uploading/downloading
- Large files editing
- Storage of interface settings in config file

Signed-off-by: Dmitry R <[email protected]>

luci-app-filemanager: Code improvements and translations

luci-app-filemanager: добавлены новые изменения
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