Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

TP: adds the ability to rearrange table columns as well as toggle column visibility#3680

Merged
rawlinp merged 19 commits intoapache:masterfrom
mitchell852:column-config
Jul 18, 2019
Merged

TP: adds the ability to rearrange table columns as well as toggle column visibility#3680
rawlinp merged 19 commits intoapache:masterfrom
mitchell852:column-config

Conversation

@mitchell852
Copy link
Copy Markdown
Member

@mitchell852 mitchell852 commented Jun 14, 2019

This PR adds the ability to show/hide table columns in TP as well as reorder the visible columns of a table. The changes made by the user will be persisted in the browsers local storage.

I tackled an easy table (the types table) to start and prove out the concept.

  • This PR is not related to any Issue

Which Traffic Control components are affected by this PR?

  • Traffic Portal

What is the best way to verify this PR?

  1. Run the UI tests
  2. Manually verify
  • Launch TP
  • navigate to Configure > Types
  • reorder columns via drag/drop on the column header
  • show/hide columns by using the following drop down

image

Note: I'm not going to document this functionality or add it to the changelog until it is added to other tables in subsequent PRs.

The following criteria are ALL met by this PR

  • This PR includes tests OR I have explained why tests are unnecessary
  • This PR includes documentation OR I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md OR such an update is not necessary
  • This PR includes any and all required license headers
  • This PR ensures that database migration sequence is correct OR this PR does not include a database migration
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

@mitchell852 mitchell852 added new feature A new feature, capability or behavior Traffic Portal v1 related to Traffic Portal version 1 labels Jun 14, 2019
@mitchell852 mitchell852 force-pushed the column-config branch 2 times, most recently from a8f1be4 to 4fda031 Compare June 14, 2019 21:54
@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 14, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3860/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 14, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3861/
Test FAILed.

@mitchell852 mitchell852 force-pushed the column-config branch 3 times, most recently from e882b33 to 6c3067a Compare June 18, 2019 20:46
@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 18, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3867/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 18, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3868/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 18, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3869/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3870/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3871/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3872/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3873/
Test FAILed.

@mitchell852 mitchell852 marked this pull request as ready for review June 19, 2019 16:20
@mitchell852 mitchell852 changed the title WIP - TP adds the ability to rearrange table columns as well as toggle column visibility… TP adds the ability to rearrange table columns as well as toggle column visibility/searchability Jun 19, 2019
@mitchell852 mitchell852 changed the title TP adds the ability to rearrange table columns as well as toggle column visibility/searchability TP: adds the ability to rearrange table columns as well as toggle column visibility/searchability Jun 19, 2019
Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

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

Still need to test things, will review again after testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The standard Storage interface doesn't appear to support indexing. It does work in Firefox, and I assume you tested it in Chrome, so maybe we don't care, but indexing seems to be non-standard and implementation-dependent. I'd recommend using Storage.getItem() instead.

This line also has an uncaught SyntaxError from that call to JSON.parse, which I guess is fine if it's somehow implicitly handled by the dataTables? Seems unlikely though.

You're also accessing a property of an object by indexing it with a string, which isn't exactly a problem in this case because of how the Storage API works, but it's a bad habit to get into because it forces type coercion on the indexed value.

Finally, you should check for the availability of the localStorage object (MDN Guide). This is because some browsers don't have localStorage (though I'm sure we don't support them), but also because sometimes it may just not be available even if it is supported. As an example, Safari's private browsing mode gives you an empty object with 0 quota on every access. It's possible that dataTablesSort or whatever it's called does this already, but you should be sure; I'm not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok, i'll see what i can clean up here. thanks

Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 Jun 19, 2019

Choose a reason for hiding this comment

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

I hate this name, because it's tying our UI directly to object representation in the database, which is meant to be opaque to Traffic Portal. But I don't have a better suggestion, so if you don't either, I guess it's fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, i'm not a fan either. it's a bad practice imo that bubbled up to the UI

Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 Jun 19, 2019

Choose a reason for hiding this comment

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

a [role="menuitem"] must be the direct child of a [role="menu"] or [role="menubar"] - you can add these roles to the <ul>, or you can get that implicitly by using a <menu> instead.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3874/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3875/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3876/
Test FAILed.

Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

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

Dude you gotta minify that new library - it's more than 10 times bigger than the previous version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wasn't this important?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no. i thought it might be useful but i never used it. there's an init function in applicationService you can use instead if you need to do something at startup.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 that sounds like a more proper use of Angular anyway.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3878/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 19, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3879/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 25, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3907/
Test PASSed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 25, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3909/
Test FAILed.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jun 25, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3911/
Test PASSed.

Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

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

Tests pass, manually tested the table changes, code looks good.

@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jul 18, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3984/
Test PASSed.

@rawlinp rawlinp merged commit 487efdc into apache:master Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

new feature A new feature, capability or behavior Traffic Portal v1 related to Traffic Portal version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants