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

Assets UI pagination #1202

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Assets UI pagination #1202

wants to merge 8 commits into from

Conversation

joshuaunity
Copy link
Contributor

@joshuaunity joshuaunity commented Oct 3, 2024

Description

Added pagination to the asset table under the account detail page

Look & Feel

Screenshot from 2024-10-03 10-09-16

How to test

  1. Vist the accounts page: Link
  2. Click on an accounts with assets

Further Improvements

Bug with icons not displaying for assets in all assets tables

Related Items

This PR resolves the issue #1201


  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

@joshuaunity joshuaunity self-assigned this Oct 3, 2024
@joshuaunity
Copy link
Contributor Author

For the changelog do I add it under New features? since this is not really a new feature.

@nhoening @Flix6x

@nhoening
Copy link
Contributor

nhoening commented Oct 3, 2024

I think it is a small new feature :)

@Flix6x Flix6x added the UI label Oct 3, 2024
@Flix6x Flix6x added this to the 0.24.0 milestone Oct 3, 2024
@nhoening
Copy link
Contributor

nhoening commented Oct 3, 2024 via email

@joshuaunity
Copy link
Contributor Author

I think it is a small new feature :)

ok, so I go ahead to add it under features?

@nhoening
Copy link
Contributor

nhoening commented Oct 3, 2024

I think it is a small new feature :)

ok, so I go ahead to add it under features?

Yes

Signed-off-by: joshuaunity <[email protected]>
@joshuaunity
Copy link
Contributor Author

I think it is a small new feature :)

ok, so I go ahead to add it under features?

Yes

I've added the log 👍

Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

It works technically!

Two larger things:

  1. You have not replaced the expensive server-side part yet:

The previous loading of all the assets (happening backend-side, here, both lines 56 and 57) still happens, so get rid of that please. No need for the CRUD endpoint to return assets.

  1. Including public assets

Here is the dilemma I found:

We included public assets (where account_idis None) in this table before, and maybe that is why you used all_accessible=true. Indeed, the asset index API endpoint is not equipped to return assets from an account and the public ones in the same response.

Our options:

  • Show two separate tables (for account assets and the public ones). Only the former would be paginated, however, and the second one might also be large.
  • Do it like the backend did, and call the asset index twice, for each set separately, then merge the result. However, this doesn't work with pagination.
  • Adapt the index endpoint to be able to add public assets separately. We'd add a parameter called include_public (defaults to False). Line 161 in the asset API would then happen if all_accessible is True or if include_public is True. Also adapt the docstring, of course.

I propose to do the third option.

P.S. As a user, I'd try to limit the search to PUBLIC assets only, by typing "PUBLIC" in the search box, but that isn't working. Maybe query_assets_by_search_terms() could accept that special case to then include public assets? It could add another query for public assets in the union_all if PUBLIC in search_terms.

flexmeasures/ui/templates/crud/assets.html Show resolved Hide resolved
flexmeasures/ui/templates/crud/account.html Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants