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

Sorting IP adresses and uptime in tables #435

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Sorting IP adresses and uptime in tables #435

wants to merge 9 commits into from

Conversation

emlun007
Copy link
Contributor

@emlun007 emlun007 commented Nov 7, 2017

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

@emlun007 emlun007 changed the title Add sorting IP adresses in tables WIP: Add sorting IP adresses in tables (help needed) Nov 7, 2017
@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 663d996 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@@ -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
Copy link
Contributor

@kirkins kirkins Nov 7, 2017

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right clicking in chrome on a date header and clicking inspect. It shows class="date".

When I do the same on anything with an IP I don't any unique class.

untitled

Copy link
Contributor Author

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

Copy link
Contributor

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'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see them as headers when I try the sorting on inventory.
ip address

Copy link
Contributor

@kirkins kirkins Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see where you were coming from, but the syntax isn't correct. Just run your selector in the console tab on chrome and you will see it returns 0 items.

untitled

Copy link
Contributor Author

@emlun007 emlun007 Nov 7, 2017

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 ?

@coveralls
Copy link

coveralls commented Nov 23, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 2a76ab0 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@emlun007 emlun007 changed the title WIP: Add sorting IP adresses in tables (help needed) Sorting IP adresses in tables Dec 21, 2017
@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling e2f37be on emlun007:patch-1 into d456d19 on voxpupuli:master.

@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling f005be3 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling f713a09 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@emlun007
Copy link
Contributor Author

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 }

@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 06349e9 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@kirkins
Copy link
Contributor

kirkins commented Dec 21, 2017

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

@@ -56,6 +56,9 @@
"search": {"regex": true},
// Default sort
"order": [[ 0, "desc" ]],
//Sort ipadresses
Copy link
Contributor

@kirkins kirkins Dec 21, 2017

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

@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 6e53055 on emlun007:patch-1 into d456d19 on voxpupuli:master.

@emlun007 emlun007 changed the title Sorting IP adresses in tables Sorting IP adresses and uptime in tables Dec 21, 2017
@coveralls
Copy link

coveralls commented Dec 21, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 2fe362a on emlun007:patch-1 into d456d19 on voxpupuli:master.

@emlun007
Copy link
Contributor Author

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate comment

@larsnaesbye
Copy link
Contributor

Can this be merged, including @vchepkov 's changes? :-)

@bastelfreak
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants