-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Sorting IP adresses and uptime in tables #435
base: master
Are you sure you want to change the base?
Conversation
puppetboard/static/js/tables.js
Outdated
@@ -16,6 +16,17 @@ | |||
else return tdTime; | |||
}); | |||
|
|||
$('thead th.IP Address').data('myIpArray', myIpArray) // save IP adresses from th. IP Addresses (unsure about the name) in myIpArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're trying to select th.IP Address
, following the pattern for .date
above.
Are you sure this class exists on any of the table headers? If there isn't a class name identifying IP Address
in the html, you'd have to add one for this to work.
If you do add it use an underscore ip_address
as CSS classes can't have spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I tried IP Address as a table header is when I import the headers from the table I get something like:
"Hostname,IP Address,OS,Architecture,Kernel Version,Reboot required,Puppet Version"
So IP Address must be a header so I wrote th.IP Address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Inventory page I can select the th
for IP Address with this:
$("table").find("[aria-label^='IP Address']")
It says find in table where aria-label
starts with 'IP Address'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the right way to do it is to use ('.dataTable td') and ('.dataTable th.IP Address'). What do you think @kirkins ?
Update: Now the ip sorter finally works 😃 All you have to do is to write column number in _macros.html which is set to 2nd column by default: { type: 'ip-address', targets: 1 } |
I'm testing this now. Everything seems to be working. On the Inventory page IP X.X.0.10 is now considered greater than X.X.0.2 for sorting. Good work @emlun007 |
puppetboard/templates/_macros.html
Outdated
@@ -56,6 +56,9 @@ | |||
"search": {"regex": true}, | |||
// Default sort | |||
"order": [[ 0, "desc" ]], | |||
//Sort ipadresses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Typo in address and add space to match with line 57. // Sort ip addresses
@kirkins , I have added code for sorting uptime (xxx days) and memory (xxx GiB). The code parses strings to integer (9.99 GiB = 9) and checks in the result is NaN. If the sourse is NaN (e.g. ip address), the original data is shown, if the source is not NaN, it is parsed to integer |
return parseInt(data)} | ||
}, | ||
], | ||
// Custom options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate comment
Can this be merged, including @vchepkov 's changes? :-) |
Sadly, it cannot be merged. This branch has merge conflicts. You can checkout the branch, resolve the conflicts and submit it as a new PR. I'm happy to review and merge it afterwards. |
I have added code in tables.js that will sort the IP adresses in inventory table. Right now, the function does not work properly, most likely because I don't use the right name of the variable with IP Adresses