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

feat: offline dashboard #1700

Merged
merged 160 commits into from
Aug 31, 2021
Merged

feat: offline dashboard #1700

merged 160 commits into from
Aug 31, 2021

Conversation

jenniferarnesen
Copy link
Collaborator

@jenniferarnesen jenniferarnesen commented Apr 12, 2021

Implements DHIS2-10874

Add offline functionality to dashboard to support Dashboard PWA. With this implementation, it is possible to cache dashboards so they can be viewed while offline. The app also detects the offline/online state, and updates availability of actions - like editing, starring, changing filters, and viewing certain info like sharing and interpretations - accordingly.

Much of this PR is about disabling/enabling buttons and menu items, and showing a tooltip. ViewDashboard is the main code for navigating to different dashboards while offline, while view/TitleBar/ActionsBar triggers the recording of a dashboard.

Additional info for some of the changed files:

Cypress tests:

d2.config.js

  • this is the config that enables offline functionality in the app-runtime. The patternsToOmit property is a list of endpoints that should NOT be cached as part of the GENERAL app cache. Therefore, the endpoints listed in this property are related to content for a specific dashboard. Endpoints that go into the general app cache include e.g. /dashboards, static assets (dashboard bundle, plugins, jquery...), /schemas, etc.

actions/selected.js

  • refactored tSetSelectedDashboardById to use async/await
  • tSetSelectedDashboardByIdOffline - this is used when user navigates to an uncached dashboard while offline. We still want to navigate to the url and set the state of the app, then when connection is restored, the rest of the data gets loaded.

Tooltip.js

  • this component is used throughout the app to apply a tooltip when the button is disabled.
    MenuItemWithTooltip.js
  • applies a tooltip to MenuItems - used for offline messages.

ConfirmActionDialog.js (refactor/code sharing)

  • used by 3 other components

DropdownButton.js

  • modifed to handle additional property disabledWhenOffline - moved that and other properties into rest

VisualizationItem/Item.js

  • need to always fetch visualization in ComponentDidMount, to handle case of dashboard being recorded.

ViewAsMenuItems.js

  • uses MenuItemWithTooltip, and the offline status will override the supplied tooltip.

DefaultPlugin.js

  • unmount visualization when the item is being removed from page. TODO: confirm changes with Jan.

ProgressiveLoadingContainer.js

  • forceLoadCount is an incrementing property that triggers force loading when a dashboard is being recorded.

PrintDashboard, PrintLayoutDashboard

  • bug fixes for bugs that the offline functionality revealed.

CacheableViewDashboard

  • adds CacheableSection which enables the dashboard to be recorded as a section.

DashboardsBar - useCallback to prevent unneeded rerendering of the content

FilterBadge.js, FilterBar.js

  • only allow removing filter if online, or if cached then user can remove, but has to remove all filters

view/TitleBar.js

  • incorporate the Last updated tag

ViewDashboard.js

  • complex logic in useEffect to determine how to handle opening dashboards depending on the offline/online state and whether the dashboard is cached. The cypress tests cover most of the scenarios.

yarn.lock.

  • yeah, just don't. I tried merging in changes from master but there were so many conflicts that were really difficult to resolve, that I ended up deleting the file and regenerating it. So lots of dependencies that have nothing to do with this feature are unfortunately in there.

@jenniferarnesen jenniferarnesen marked this pull request as draft April 12, 2021 14:02
@jenniferarnesen jenniferarnesen force-pushed the feat/offline-dashboard branch from 8e3e002 to efe6f69 Compare April 23, 2021 10:36
type="button"
<Tooltip
content={i18n.t(
'Cannot confirm changes while offline'
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this tooltip conditionally rendered based on !filtersSelectable or the online status to not show when online?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tooltip is for when the button is disabled due to being offline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. I am only adding functionality for offline. Nothing else has changed unless I'm missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, I thought, since this is wrapping the "confirm" button, which I thought would be visible both online and offline, that the tooltip would then also be (incorrectly) visible when online. The button has a if (!filtersSelectable) condition, but the tooltip has none. But maybe Im missing something, hard to judge when you just look at this in isolation.

Copy link
Contributor

@martinkrulltott martinkrulltott left a comment

Choose a reason for hiding this comment

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

Reviewed, see separate comments with suggestions and questions.

@jenniferarnesen jenniferarnesen merged commit 4103643 into master Aug 31, 2021
@jenniferarnesen jenniferarnesen deleted the feat/offline-dashboard branch August 31, 2021 21:08
dhis2-bot added a commit that referenced this pull request Sep 1, 2021
# [31.18.0](v31.17.9...v31.18.0) (2021-09-01)

### Bug Fixes

* disable or delete cypress tests that are currently broken [v37] ([#1925](#1925)) ([#1926](#1926)) ([264a999](264a999))
* migrate from chart/pt to visualizations ([#1916](#1916)) ([b313a39](b313a39))

### Features

* dashboard layout (DHIS2-3600) ([#1803](#1803)) ([75da018](75da018))
* offline dashboard ([#1700](#1700)) ([4103643](4103643))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 31.18.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@jenniferarnesen jenniferarnesen restored the feat/offline-dashboard branch November 26, 2024 13:17
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.

4 participants