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
Optionally group file list by subfolder #86
Optionally group file list by subfolder #86
Conversation
What would you say to using Symfony's Finder to gather the file paths in stead of protected function getFilePaths(): array
{
$finder = Finder::create()->in(storage_path('logs'))
->files()
->depth(config('log-viewer.search_depth', 0))
->name(config('log-viewer.include_files', []))
->notName(config('log-viewer.exclude_files', []))
->sortByModifiedTime()
->reverseSorting();
return array_keys(iterator_to_array($finder));
} Then I could just include |
Okay, so I misremembered how Finder's I've pushed a simpler implementation which allows users to turn recursive search on (off by default) via a new |
@mortenscheel hey! Thanks a lot for the PR 😄 Here's my thoughts:
I'd really like to wait with this PR until the timestamps PR gets merged (this weekend or earlier) because it has quite a few changes to the UI as well. It will then also make it a lot easier to bring forth true collapsible folders into the UI. |
I have tested this with windows, and it does parse it properly. Something that I noticed while testing this out was the In my opinion, this change from Now, talking about the original PR changes, the UI could be formatted such that there will be space between the directory separators. @arukompas yes, |
@arukompas sounds great. If you want to make Finder handle the timestamp sorting, you can just do like in my example: Here's the missing screenshot. I've just added a .text-gray-400 header above each subfolder. |
@arukompas This PR is really just a proof of concept, and I agree that migrating from glob to Finder requires more consideration and should be a separate PR. You're welcome to close this PR if you wish, and ping me later if you'd like some help. |
Hey @mortenscheel , thanks for great insights! I do feel like Symfony finder would be a great addition, but it would be a breaking change if we swapped to it completely. Instead, we could use Symfony's finder in addition to glob patterns which users already use in their Speaking of folders - just tagged Other than that, the PR gave me some great thoughts and taught me about Symfony finder! :D But I'll be closing this for now as it's not something we should introduce just yet. Perhaps in v2 where we can have breaking changes. |
I have a project which requires 2 globs in order to find all the log files (both directly in the logs folder and in subfolders)
This makes the file list a bit unintuitive, since the first file isn't necessarily the most recent.
So I've tried to add the ability to group the file list by subfolder.
The root folder is always first, then subfolders are listed in alphabetical order.
It's just a quick proof of concept. Let me know if you want some changes.
By the way, it's necessary to run
view:clear
to get rid of the old version of file-list.blade.php. I thought the blade compiler would automatically detect that the cached view should be replaced. Is it that just how it is with vendor blade views?