-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement loading spinner [DHIS2-20124] #74
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
Conversation
🚀 Deployed on https://pr-74.event-visualizer.netlify.dhis2.org |
There was a problem hiding this 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 💪
src/components/plugin-wrapper/hooks/use-line-list-analytics-data.ts
Outdated
Show resolved
Hide resolved
src/components/plugin-wrapper/hooks/use-line-list-analytics-data.ts
Outdated
Show resolved
Hide resolved
src/components/plugin-wrapper/hooks/use-line-list-analytics-data.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
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 returnsnull
, 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 needvisualization.type
). In this case only the spinner is rendered.Once the visualization fetch is completed, the
isVisualizationLoading
flag is set tofalse
.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 is
hasAnalyticsData
implemented as local state inPluginWrapper
.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
Known issues
a double analytics fetch happens, this might be only in dev mode, but it needs to be avoidedSolved 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:

Fetch overlay shown when sorting/paginating or updating a visualization when editing:
