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

Enhancement #500 Export bootstrap-table #526

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

Conversation

nvcastelli
Copy link

Description

This changes utilizes the bootstrap-table export plugin to pull table data from tables within the Dependency Track application. In places where it's been enabled on a bootstrap table users will be able to select a dropdown to download table data based on the file type they select.

Addressed Issue

This PR is the first step to fulfilling the following enhancement #500. Pending approval this should resolve enhancement #500

Additional Details

We had brought up this enhancement and Steve suggested using the bootstrap-table export plugin. Currently, this change only adds the ability to download on the component table and only in json and txt formats. I am looking into adding the ability to download as an excel but there are more dependancies needed.

For this change to work some new dependencies need to be included:

  • js-xlsx
  • tableexport.jquery.plugin
  • file-saver

I'm happy to add any suggestions.

Checklist

@nvcastelli nvcastelli changed the title Export table Export bootstrap-table Jun 14, 2023
Adding dependancies and functionality for table export

Signed-off-by: Nicholas Castelli <[email protected]>
@nvcastelli nvcastelli changed the title Export bootstrap-table Enhancement #500 Export bootstrap-table Jun 14, 2023
@nscuro
Copy link
Member

nscuro commented Jul 8, 2023

Hi @nvcastelli, thanks for the PR!

For this change to work some new dependencies need to be included:

  • js-xlsx
  • tableexport.jquery.plugin
  • file-saver

Could you please add those dependencies to package.json via npm install, so this change can be tested?

@nvcastelli
Copy link
Author

Hey @nscuro, I was able to add those dependancies, please let me know if there's anything else you need from my end.

@nscuro
Copy link
Member

nscuro commented Jul 25, 2023

@nvcastelli I just gave this a spin, but it seems like despite usage of exportDataType: 'all', the export still only contains only up to 100 components.

The issue seems to be that, in order to fetch all items, the plugin requests the REST endpoint without pageNumber / pageSize query parameters, e.g.:

http://localhost:8081/api/v1/component/project/f803526f-fe36-4485-ae0b-e7fe463caf18?onlyOutdated=false&onlyDirect=false&searchText=&sortName=name&sortOrder=asc

Whereas in the paginated view it would do:

http://localhost:8081/api/v1/component/project/f803526f-fe36-4485-ae0b-e7fe463caf18?onlyOutdated=false&onlyDirect=false&searchText=&sortName=name&sortOrder=asc&pageSize=25&pageNumber=1

For paginated REST endpoints, DT will fall back to pageNumber=1 and pageSize=100 when not set explicitly:

https://github.com/stevespringett/Alpine/blob/cd6aa7ed05376935ab32bc43819eba0e3a525b7f/alpine-infra/src/main/java/alpine/persistence/Pagination.java#L58-L65

If the intention is to truly fetch all components, we'll need a way to deal with DT's default pagination behavior here.

@nvcastelli
Copy link
Author

Hey @nscuro , thank you for looking into it. My understanding is that the export-table functionality sets the pagesize to the amount of items in the list, then pulls from them that way. But if you're saying it only does that up to a maximum 100 that would be a problem. If we want to keep using these plugins we'd have to look into how DT does the pagination like you mentioned. Another option may be to just grab the data that's returned from the request to fill the table and put it into a file. Not sure if there's a good plugin for this, maybe something we'd have to make from scratch. Let me know your thoughts, and thanks again!

@nscuro
Copy link
Member

nscuro commented Jul 25, 2023

My understanding is that the export-table functionality sets the pagesize to the amount of items in the list, then pulls from them that way.

In that case I'd have expected it to set pageNumber=1&pageSize=N for a project with N components, but that was not happening when I tested it.

If we want to keep using these plugins we'd have to look into how DT does the pagination like you mentioned.

Maybe there's a hook or callback we can use to manually populate the request parameters?

Another option may be to just grab the data that's returned from the request to fill the table and put it into a file.

Yeah, at that point it may be easier to do it in the API server altogether. I personally do not have strong feelings about the bootstrap plugins, but I understand Steve would appreciate us making it work somehow using this plugin.

@leec94
Copy link

leec94 commented Aug 30, 2023

hi @stevespringett looks like the recommended plugin isn't working as we'd like. there's some discussion around researching other directions to implement this, would you be open to us researching other plugins or getting the data from the backend instead?

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.

3 participants