Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Sort the DHCP reservation list by any column #914

Closed
wants to merge 5 commits into from
Closed

Sort the DHCP reservation list by any column #914

wants to merge 5 commits into from

Conversation

winternet-studio
Copy link

A completely self-contained solution for adding sorting of the manually assigned IPs on the DHCP page. You can sort by any of the 3 columns: MAC, IP, and Hostname.

Made a clean and modular solution that interfere as little as possible with existing code and is easy to disable in case it becomes incompatible with future versions. Requires jQuery but that seems to already be loaded on the page.

Tested in recent versions of Firefox, Chrome, IE.

@RMerl
Copy link
Owner

RMerl commented Mar 13, 2016

Asus is currently doing a lot of changes to the webui to link it to the new improved networkmap. That code isn't present yet on Github as it's still beta GPL code. It means there's a chance that a lot will change on that page by the time it gets merged in.

@winternet-studio
Copy link
Author

Ok. If they don't add the feature themselves I'm ready to adjust my script at that time if need be.

@RMerl
Copy link
Owner

RMerl commented Apr 23, 2016

I should be done with major changes to the DHCP page for now (I merged support for the new networkmap code), so feel free to update this patch to adapt to the new code (first col data must be accessed through .title rather than .innerHTML now).

@winternet-studio
Copy link
Author

I don't see that your changes interfere with my code. The only thing I modify on the page is the dhcp_staticlist_array variable and as far as I can read the code it has not been changed. After I modify that I just call the standard showdhcp_staticlist() function...

I don't know how to test it since it is read-only on the router - unless you can direct me to guide of how to temporarily put the new file on the router?

@RMerl
Copy link
Owner

RMerl commented Apr 28, 2016

You could recompile the firmware with your patches applied on top of it.

Otherwise, copy the content of /www to your USB disk, edit/add your files there, then bind it on top of the original directory:

mount -o bind /mnt/USBDISK/copy-of-www /www
service restart_httpd

The server will then use whatever is stored in that writable copy, until next reboot.

(But how do I moved this pull request to the master branch and 380.59-beta1 tag?)
@winternet-studio
Copy link
Author

Excellent! Have enhanced my code to work with the new file and tested that it works. Have committed the new file here but I don't know how to move it to the right tag (380.59-beta1) - can you do that? And the single added line in Advanced_DHCP_Content.asp must come AFTER the line with /js/jquery.js in the new file.

@RMerl
Copy link
Owner

RMerl commented Apr 28, 2016

Worst case scenario I guess it will create a separate branch, from which I can either merge back on master, or cherry-pick your commits.

I'll see if I can find some time to merge and test things out before 380.59 beta2, otherwise I'll schedule it for 380.60.

@RMerl
Copy link
Owner

RMerl commented May 6, 2016

Found two issues:

  1. Sort method isn't reversible on all three columns. Resolved by adding a reverse item to the merlinWS object, and referring to its value to control the sort order. So, in sortBy:
merlinWS.reverse = merlinWS.reverse == 1 ? -1 : 1;
  1. something is wrong with the MAC address field sort. Forward sort uses the MAC, but reverse sort uses the Name field.

@RMerl
Copy link
Owner

RMerl commented May 6, 2016

Code manually merged inside Advanced_DHCP_Content.asp, currently sitting on the sortdhcp branch. I fixed the toggleable sort order, only issue left is the MAC field sort.

@winternet-studio
Copy link
Author

I purposely didn't implement reverse sorted since I thought I had some kind of issue with (but forgot what) and thought that it wasn't really needed anyway. But if you got it working fine, great.

In the latest version it also showed the name field together with the MAC address, that's why I made it toggle between sorting on MAC address and Name field. (That was also a factor that would complicate the UI for doing reverse sorting) But if you want to have reverse sorting instead of being able to sort by the name you need to change this:

merlinWS.sortStaticIpList(merlinWS.firstCol_newSortIndex);

to

merlinWS.sortStaticIpList(0);

and then remove all references to firstCol_newSortIndex.

@RMerl
Copy link
Owner

RMerl commented May 10, 2016

Thanks, got it working.

I decided to go with reversable sort for sake of consistency - everyone expects columns to sort in reverse order when clicking a second time on it.

@RMerl
Copy link
Owner

RMerl commented May 10, 2016

Final version of the patch merged with commit 6a8ed67 .

@RMerl RMerl closed this May 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants