Skip to content

Conversation

edoardo
Copy link
Member

@edoardo edoardo commented Oct 8, 2025

Implements DHIS2-20124

Description

Implement a loading spinner in the PluginWrapper component.
This spinner shows while a visualization is fetched (opened via StartScreen, File -> Open or by changing the URL) and while the analytics data for such visualization is fetched.

There are different scenarios depending on the presence of a (previous) visualization object in the Redux store (currentVis).
If currentVis is present (ie. I'm looking at a visualization and decide to switch to another one) the LL/PT plugin is rendered in addition to the loading spinner. In this case, when analytics data is not available, the plugin returns null, otherwise the (previous) visualization is rendered but covered by the spinner.
If currentVis is not present, is not possible to render the specific plugin, because we don't know which one to use (we need visualization.type). In this case only the spinner is rendered.
Once the visualization fetch is completed, the isVisualizationLoading flag is set to false.
This partially controls the visibility of the spinner.
The spinner keeps remaining visible until the analytics data is returned, the hasAnalyticsData internal state flag is used for this.
This spinner is then only visible when fetching a visualization from the server.

Another scenario is when a visualization is loaded but changes are made and the Update button is clicked.
In this case the currentVis changes, but there isn't any visualization fetch, isVisualizationLoading remains unchanged and the spinner is not shown.
The visualization plugin (LL, PT...) renders the fetch overlay, which shows a spinner on top of the visualization while the new analytics data is fetched.

Similarly, when sorting or paginating the fetch overlay is shown while the new analytics data is fetched.

For all this to work, we need some information passed to the plugin components.

isVisualizationLoading comes either from the app's Redux store or from the local state in the dashboard plugin.
The other flag needed ishasAnalyticsData implemented as local state in PluginWrapper.
This flag is used to control spinner between the visualization fetch and the analytics fetch when there is a "time gap" before the plugin components can render something.

The fetch overlay has also been adjusted to blur the table content instead of showing the dark grey background.


Quality checklist

Add N/A to items that are not applicable and check them.


TODO

  • decide if the blurring effect should cover the whole table including the headers and the pagination controls. The fetch overlay still covers the whole table, so interaction with pagination and sorting buttons is blocked while analytics data is fetched.

Known issues

  • a double analytics fetch happens, this might be only in dev mode, but it needs to be avoided Solved by calling the analytics fetch "manually", the hook now returns a function instead of performing the fetch directly.

Screenshots

Main spinner when loading a visualization and waiting for analytics data to return:
Screenshot 2025-10-10 at 15 38 35

Fetch overlay shown when sorting/paginating or updating a visualization when editing:
Screenshot 2025-10-10 at 15 38 53

@dhis2-bot
Copy link

dhis2-bot commented Oct 8, 2025

🚀 Deployed on https://pr-74.event-visualizer.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify October 8, 2025 14:09 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 9, 2025 12:43 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 10, 2025 13:29 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 10, 2025 13:56 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 10, 2025 14:44 Inactive
Copy link
Collaborator

@HendrikThePendric HendrikThePendric left a comment

Choose a reason for hiding this comment

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

I think there are still some minor points to address, but in general I think the solution you are working towards seems perfect. You've found an elegant way to differentiate between the "clear data and reload" and the "fetch new data" scenario in a very elegant way 💪

@dhis2-bot dhis2-bot temporarily deployed to netlify October 13, 2025 11:33 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 13, 2025 11:41 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 13, 2025 11:51 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 13, 2025 12:23 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 13, 2025 13:28 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 15, 2025 10:48 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 08:14 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 10:04 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 10:15 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 10:26 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 10:32 Inactive
@HendrikThePendric HendrikThePendric self-requested a review October 16, 2025 11:51
@edoardo edoardo marked this pull request as ready for review October 16, 2025 13:05
@dhis2-bot dhis2-bot temporarily deployed to netlify October 16, 2025 13:07 Inactive
@edoardo edoardo changed the title feat: implement loading spinner DHIS2-20124 feat: implement loading spinner [DHIS2-20124] Oct 16, 2025
Copy link
Collaborator

@HendrikThePendric HendrikThePendric left a comment

Choose a reason for hiding this comment

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

🎉

@edoardo edoardo merged commit c0bba1e into master Oct 16, 2025
12 checks passed
@edoardo edoardo deleted the feat/loading-state-DHIS2-20124 branch October 16, 2025 14:37
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