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

Record sort order in URL for auto-refreshing #439

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

Conversation

kirkins
Copy link
Contributor

@kirkins kirkins commented Nov 7, 2017

This is a code snippet that allows the sort order to be controlled via a URL parameter set by clicking on a table header. #314

@kirkins
Copy link
Contributor Author

kirkins commented Nov 7, 2017

@mterzo let me know if this is Ok so far. If so I will add a second parameter for ascending vs descending.

@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling 85a957b on kirkins:patch-6 into d456d19 on voxpupuli:master.

@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage remained the same at 81.76% when pulling aa89129 on kirkins:patch-6 into d456d19 on voxpupuli:master.

@mterzo
Copy link
Contributor

mterzo commented Nov 7, 2017

We shouldn’t have to post back to the server on this. I haven’t had a chance to look but most JS sort library’s have a display to show and an actual value. For IPs we just need to conver them to their interfered value.

@mterzo
Copy link
Contributor

mterzo commented Nov 7, 2017

I’m also looking into the larger scale installations where we are causing too many queries back to PuppetDB. If we don’t have to requery data we already have that would be helpful. Of course if we are paging the results the sort is on the result set not the entire data set.

@kirkins
Copy link
Contributor Author

kirkins commented Nov 7, 2017

@mterzo this doesn't post back to the server I'm using an HTML5 feature that lets you update the URL without querying the website.

https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method

Also this isn't related to the IP sorting. It is related to the fact that Puppetboard automatically refreshes every X seconds and forgets which column the user was sorting by.


// When a table header is clicked update the URL without refreshing page
$("th").click(function() {
var newUrl = location.origin + location.pathname + "?sort=" + $(this).text();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would have to replace the above location.origin with polyfill too.

// When a table header is clicked update the URL without refreshing page
$("th").click(function() {
var newUrl = location.origin + location.pathname + "?sort=" + $(this).text();
history.pushState({}, null, newUrl);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mterzo this probably isn't compatible with older browsers. I'll do some more research this week.

Copy link
Contributor

Choose a reason for hiding this comment

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

It works for Internet explorer 👍

@bastelfreak
Copy link
Member

@mterzo can you please have a look at this?

@kirkins kirkins mentioned this pull request May 25, 2019
@raphink
Copy link
Member

raphink commented Jul 29, 2020

This works fine for me, but it only records the sort key, not the order (desc or asc).

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

Successfully merging this pull request may close these issues.

6 participants