Author: Currently updated and maintained by @millacurafa for PAHO/CIM. Originally developed by @jakub-bao and @plinnegan.
Version: 3.1.0
The DHIS2 Rich Text and Video Dashboard Widget is a WYSIWYG editor for creating rich content in DHIS2 dashboards. Internally, the widget is called Information.
- Two builds from one codebase:
dashboard-information-widget-v40.zip(legacy widget for DHIS2 40 and earlier) anddashboard-information-widget-v42.zip(App Platform dashboard plugin for DHIS2 42, built with@dhis2/app-runtimeand@dhis2/ui). - Opening the app directly from the app menu now shows a translated notice instead of an error.
- Support for configurable iframe domains through the DataStore (
allowedIframeDomains). - User-friendly error message when an iframe from a non-allowed domain is displayed.
- Compatibility with DHIS2 v42 and modern URLs.
- Sanitization bug fixes and improved handling of images and videos.
- Author updated to PAHO/CIM.
- Added multilanguage support
- Install the app via the App Hub or by uploading the matching zip into the DHIS2 App Management app:
dashboard-information-widget-v40.zipfor DHIS2 40 and earlier (legacyDASHBOARD_WIDGET).dashboard-information-widget-v42.zipfor DHIS2 42 (App Platform dashboard plugin).- The v42 build keeps the same app key (
Information) and data store namespace (dashboard-information) as the legacy widget, so uploading it over the existing app keeps your dashboards and saved content working.
- Be sure to grant access to the app to all users, or they will not see the content. To do this, go to DHIS2 Users > User role > [role] > Apps > select
Information app. Make sure to do this on enough roles to give all users access. (For example, if all users on your system have a Guest or Read Only role, giving the permission to that role is sufficient.) - From the Dashboards page of your DHIS2 installation, edit a dashboard. (If you do not have any dashboards, you will need to add a new dashboard.)
- Click
Search for items to add to this dashboard, and selectInformationunderApps. - Click the Edit button on the Information widget to create content.
- If you would like to restrict the creation and editing of Information content to superusers, go to the Datastore Manager, select the
dashboard-informationnamespace, then theconfigurationkey, and check theOnly open to superusersbox. (This namespace and key will only be present after you have created an Information widget.) - To resolve the error
Refused to connectafter you add it to the dashboard, check the following server configurations:-
Remove conflicting X-Frame-Options headers: Ensure your web server (NGINX, Apache, or Tomcat) does not set multiple conflicting values like
SAMEORIGIN,DENY. It should be set cleanly toSAMEORIGIN.For instance, Nginx config could need to be updated to allow the application to run. Change this line in your nginx config:
add_header X-Frame-Options DENYto
add_header X-Frame-Options SAMEORIGIN -
Update Content Security Policy (CSP): If your server uses a
Content-Security-Policyheader, ensureframe-ancestors 'self'is properly declared so the app is allowed to frame itself. -
Add to CORS Whitelist: Ensure your instance or domain setup is correctly configured in the DHIS2 system settings under System Settings -> Access -> CORS Whitelist.
-
- Install all dependencies:
npm i. - Set up your server URLs in
serverConfig.dev.jsonandserverConfig.prod.json. - Edit
public/manifest.webappto specify the app name for your DHIS2 instance (v40 build). The v42 manifest is generated fromplatform/d2.config.js. - Run locally with
npm start. - Build the v40 zip with
npm run build:v40. - Build the v42 zip (App Platform, in
platform/) withnpm run install:platformonce, thennpm run build:v42. npm run buildbuilds both zips into the repository root.
- In the editor, use the video/embed option and paste an iframe embed URL.
- Recommended YouTube format:
https://www.youtube.com/embed/<VIDEO_ID> - The sanitizer strips unsafe scripts and keeps only allowed hosts/attributes.
If videos appear while editing but later become placeholders, enable debug mode and inspect the full content pipeline.
- Enable with URL flag: add
widgetDebug=1in query or hash.- Example:
.../api/apps/dashboard-information/index.html#/edit?widgetDebug=1
- Example:
- Or enable from browser console:
localStorage.setItem('dashboard-information-debug', '1')- Reload the app.
- Disable from browser console:
localStorage.removeItem('dashboard-information-debug')
When enabled, console lines prefixed with [DIW DEBUG] will show a visible summary for every event:
- Raw content fetched from DataStore
- Content after sanitization
- Content before and after
contentHookcleanup - Content before save request
- Final content rendered
Each event includes iframe diagnostics (iframeCount, iframeWithoutSrcCount, iframeSrcs, and Jodit wrapper detection) to identify the exact stage where src is lost.
Extra console helpers:
window.__diwDebugDump()prints a table with all events.window.__diwDebugLast()returns the latest raw debug event object.
This widget now supports two translation layers:
- Interface translations (buttons, messages, alerts)
- Dashboard content translations (rich text/video body per language)
The widget resolves active locale in this order:
- URL override (
?lang=esor?locale=fr) whenAllow locale overrideis enabled - DHIS2 user locale (
/meprofile settings) - Widget default locale from DataStore configuration
en
In namespace dashboard-information, key configuration, the app reads:
Only open to superusers(existing behavior)Default locale(example:en)Supported locales(example:['en', 'es', 'fr', 'pt'])Allow locale override(boolean)
If these keys do not exist, the app initializes defaults automatically.
Each widget item now supports:
{
"body": "<p>Latest saved content</p>",
"defaultLocale": "en",
"bodyByLocale": {
"en": "<p>English content</p>",
"es": "<p>Contenido en espanol</p>",
"fr": "<p>Contenu en francais</p>",
"pt": "<p>Conteudo em portugues</p>"
}
}Backwards compatibility is preserved:
- If
bodyByLocaleis missing, the widget still renders legacybody. - Saving from the editor writes locale-aware structure automatically.
- Open widget edit mode.
- Use the Language selector above the editor.
- Update content for the selected locale.
- Save.
The render view will show the best available fallback if current locale content is not present.
UI strings are managed in:
src/modules/shared/services/i18n.service.ts
To add a language (example pt):
- Add
ptunder each translation key indictionary. - Add
pttoSupported localesin DataStore configuration. - Optionally set
Default localetopt.
- Add
?lang=esor?lang=frto widget URL. - Or disable override and test with users that have different DHIS2 locale preferences.
Please create an issue or a pull request.
Updated and maintained by @millacurafa PAHO/CIM.
Originally developed by @jakub-bao and @plinnegan. Currently updated and maintained by PAHO/CIM.
