-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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-base: fix sort order for size columns #6643
Conversation
Currently elements of package size, packet size, etc. columns are interpreted as text strings, so we have "800 B" > "7.54 KiB" > "5.11 MiB". To fix this, a new regexp is added to UITable.deriveSortKey. It is still not a perfect fix for System->Software->Installed, since pagination is done based on package names, so within each page the packages are sorted correctly, but the smallest (resp., largest) package is not necessarily on the first (resp., last) page. Closes: openwrt#5994 (see also openwrt#6120) Signed-off-by: Rani Hod <[email protected]>
@jow- Would you please take a look? |
I think a better solution is adding a |
Maybe this should be the only value, and let css magic do the text formatting for rendering? |
CSS magic can't do that as far as I know. |
I came to suggest this. Exclude any units from the numeric value, and append those at a later stage, so sorting is done on raw numbers. |
This looks related to #4087 |
@systemcrash my JS skills are not sufficient to make the recommended changes. Should I close the PR? |
Have a crack at it. This is a great learning opportunity. |
Are there currently any tables left requiring this change? While I agree that it might be nice to smartly detect formatted size values and sort them accordingly, the proper fix should be adjusting affected tables to contain a See for example commit 4f4ad9b which fixed some tables shown in the nlbwmon application. The underlying capability to the UITable class has been added in 90a2b1e |
Does the sorting logic then depend in the browser?
|
I don't understand that question. Why should it depend on the browser? |
Because the data is at the client, and the client is the users web browser. So column sorting is performed by the browser. Or? |
Uhm, yes but the current sorting is done by the browser as well? |
It should not be done at the browser, |
There is no server side rendering in LuCI anymore, all data is rendered locally in the browser by building the table DOM from a multi dimensional array (or, in some cases by reading JS generated HTML table DOM and translating it into an internally table representation which is then eventually re-rendered) so sorting happens in the browser as well, naturally. There's also no paging for the most part. The only paging I can think of is the software package list in the opkg menu, but that is rendered browser-side as well, it actually parses the raw package metadata list locally using JavaScript and dynamically builds the tables and paging logic |
So pagination of data should also happen at the browser.
|
It is, there is no single server side rendered/paged table view in LuCI within this repository I am aware of. The only exception should be the opkg package list display, but neither this PR nor the existing quick column sort logic will fix sorting across it's paged views. Solving that would require reworking the entire opkg view (or building paging logic right into the |
Looking at that page (/cgi-bin/luci/admin/system/opkg ?), also this seems to get all data at once (an almost 5 MB data chunk), which is then locally paginated. So, it seems what @jow- suggests should be possible, including sorting across pages (which currently does not work). |
@knarrff was opkg page your only concern here? |
I did not have a particular page in mind, but assumed that pagination happens because it would reduce bandwidth usage. That pagination is not done server-side should make sorting a whole lot easier. |
Would you like to try and add the necessary fields using this PR that @jow- highlighted earlier here? |
I'll try this, thanks. |
@raenye Do you have an update? |
Currently elements of package size, packet size, etc. columns are interpreted as text strings, so we have "800 B" > "7.54 KiB" > "5.11 MiB". To fix this, a new regexp is added to
UITable.deriveSortKey
.It is still not a perfect fix for System->Software->Installed, since pagination is done based on package names, so within each page the packages are sorted correctly, but the smallest (resp., largest) package is not necessarily on the first (resp., last) page.
Closes: #5994 (see also #6120)