this repository builds:
- a docker image ghcr.io/openimis/openimis-fethat can be use in a docker compose
- a minified js application that can be served by any webserver (see release)
the build content is defined by the openimis.json file
more information for:
| When programming for openIMIS frontend, the shared (with openimis-fe_js) dependencies (react,...) must be declared as *peerDependencies* in your package.json file. You are also highly encouraged to used the features provided in the openimis-fe-core module. This includes (but is not limited to) main menu entries, date handling, user info,... Another important point is NOT TO HAVE in backend db table user_Core (managed by Django) user called 'admin' or 'Admin'. This could case defects while running frontend via command `yarn start`. This issue is related to the link between userCore and tblUser tables. | 
- clone this repo (creates the openimis-fe_jsdirectory)
- install node (node V16.x)
- install yarn
- within openimis-fe_jsdirectory- generate the openIMIS modules dependencies and locales (from openimis.json config): yarn load-configoryarn load-config openimis.json
- install openIMIS technical dependencies: yarn install
- start openIMIS frontend (in development mode): yarn start
 
- generate the openIMIS modules dependencies and locales (from openimis.json config): 
- 
within openimis-fe_jsdirectory- generate the openIMIS modules dependencies and locales (from openimis.json config): yarn load-configoryarn load-config openimis.json
- clean yarn cache in case local directory / git /link are used: yarn cache clean
- install openIMIS technical dependencies: yarn install
- build openIMIS frontend (in development mode): yarn build
- copy the build folder on the webserver
 
- generate the openIMIS modules dependencies and locales (from openimis.json config): 
```{
	"name": "CoreModule", // If name is not provided, it will assume the module is exported as the `default` module
	"npm": "@openimis/[email protected]"
}```
At this stage, your browser opened on localhost:3000 with current openIMIS frontend. In developement mode, the frontend connects to the backend via a proxy configuration, expecting to reach the backend on localhost:8000 (cfr. /package.json file, "proxy" entry).
- checkout the module's git repo NEXT TO (not within!) openimis-fe_jsdirectory and create a git branch for your changes
- from openimis-fe-claim_js- install module dependencies: yarn install
- build current (dev) version of the module: yarn build
- prepare a linkable version of your local package: yarn link
 
- install module dependencies: 
- from openimis-fe_js- uninstall the packaged module you want to work on (example @openimis/fe-claim): yarn remove @openimis/fe-claim
- link the local version of the module: yarn link "@openimis/fe-claim"
 
- uninstall the packaged module you want to work on (example @openimis/fe-claim): 
Note:
- It is not necessary to register a linked module in the package.json file
- To unlink a previously linked package: yarn unlink "@openimis/fe-claim"
- [OPTIONAL] To enable live reload of the module, from openimis-fe-claim_js, activate the watch:yarn start(if configured into thepackage.jsonof the module)
- create a (git-enabled) directory next to the other modules: /openimis-fe-mymodule_js. Note: the module name can be different from the directory/github repo. The npm repo has an @openimis scope to group all openIMIS modules
- to be integrated in openIMIS ecosystem, you module should provide an entry entity (e.g. MyModule) with its contributions (MainMenu entries,...).
- prepare a linkable version of your local package: yarn link(from within/openimis-fe-mymodule_js)
- from /openimis-fe_js:
- install the linkable version of your package: yarn link @openimis/fe-mymodule
- add your module (name and entry entiry) in openimis.jsonand regenerate the modules import script:node module-requirements.jsNote: to ease development lifecycle, please consider using the 'rollup' mechanism (see @openimis/fe-core for an example)
 
- install the linkable version of your package: 
To create a distinct implementation of an existing openIMIS module (e.g. @openimis/fe-location-dhis2)
Unlike backend modules, there is 'shared logical name' between distinct implementations of a same 'module'. If you want to provide an distinct implementation for locations (example), just create a separate module, with a distinct module name and ensure the packaging (distribution) picks your module (and not the reference implementation).
- adapt your package.json (bump version number, ensure license is mentioned,...)
- commit your changes to the git repo and merge to master
- tag the git repo according to your new version number
- publish to npm central repo: npm publish(from within/openimis-fe-mymodule_js) Note: you'll need to login,... (cfr. https://docs.npmjs.com/cli/publish)
Note: As a distributor, you may want to run an openIMIS version without docker. To do so, follow developers setup here above (up to starting the server with yarn start).
- clone this repo (creates the openimis-fe_js directory) and create a git branch (named according to the release you want to bundle)
- adapt the openimis-fe_js/openimis.json to specify the modules (and their versions) to be bundled
- make release candidates docker image from openimis-fe_js/: docker build . -t openimis-fe-2.3.4
- run the docker image: docker run -p 8080:80 openimis-fe-2.3.4(exposing the 80 port to 8080 port of docker host)
When release candidate is accepted:
- commit your changes to the git repo
- tag the git repo according to your new version number
- upload openimis-be docker image to docker hub
Note: This image only provides the openimis frontend server. The full openIMIS deployment (with the backend,...) is managed from openimis-dist_dck repo and its docker-compose.yml file.
- 
from /openimis-fe_js:- run this command: node dev_tools/installModuleLocally.js <repourl> <branch>
- for example node dev_tools/installModuleLocally.js https://github.com/openimis/openimis-fe-contract_js.git develop
 
- run this command: 
- 
this command executes every steps to install module locally. Those steps are: - Download module from GitHub repository using git clone.
- Go into module directory
- Within this directory run yarn install,yarn buildandyarn link(according to that provided order)
- Within openimis-fe_js:
 - 
execute yarn remove @openimis/fe-invoice
- 
In openimis.json openimis add: { "name": "ContractModule", "npm": "@openimis/[email protected]" }
- 
Edit package.json - in "dependencies" put or update this module that you want to run from local environment: { ... "dependencies": { ... "@openimis/fe-contract": "file:../openimis-fe-contract_js", ... } ... }
- 
execute node modules-config.js
- 
run yarn link <module>for example:yarn link "@openimis/fe-contract"
- 
run yarn install
 
- 
after this you can execute yarn startand you should see local module in your imis application.
- from /openimis-fe_js:- run this command: node dev_tools/addCIToModule.js <moduleNameDirectory>
- for example node dev_tools/addCIToModule.js openimis-fe-invoice_js
 
- run this command: 
- this command allows to add files to execute CI on every PR and allows to publish to npm.
- if .github/workflowsdoesn't exist in particular module, this directories are created while running this command
- files to be added through that command based on provided templates:
- CI_and_build.yml
- npmpublish.yml
 
- those files are saved in .github/workflows
- from /openimis-fe_js:- run this command: node dev_tools/installModuleLocallyAll.js. This command will execute all required steps to fetch all modules present inopenimis.jsonfrom the git repositories and install them as editable libraries.
 
- run this command: 
- create separate new module based on frontend template module.
- this module should be named like: openimis-fe-language_{lang}_jsfor exampleopenimis-fe-language_es_js(Spanish language)
- add to this module such files as: .babelrc,.gitignore,.estlintrc
- within src/translationadd{lang}.jsonfile for examplees.json
- in index.jswithinsrcmodified (for example we want to have 'es' Spanish language):
       import messages_es from "./translations/es.json";
       const DEFAULT_CONFIG = {
           "translations": [{ key: "es", messages: messages_es }],
       }
       export const LanguageEsModule = (cfg) => {
           return { ...DEFAULT_CONFIG, ...cfg };
       }- build your new module with translations by typing within this module yarn build,yarn installandyarn linkcommands.
- in tblLanguageson database level add new language for example 'es' (Spanish language)
- within assembly frontend module openimis-fe_jsinopenimis.jsonadd language key for new language/localization for example:
      ...
       "locales": [
       {
          "languages": [
            "es",
            "es-ES"
          ],
          "intl": "es-ES",
          "fileNames": "es"
       },
       {
          "languages": [
            "en",
            "en-GB"
          ],
          "intl": "en-GB",
          "fileNames": "en"
        },
        {
          "languages": [
            "fr",
            "fr-FR"
          ],
          "intl": "fr-FR",
          "fileNames": "fr"
        }
      ],
      ...- in openimis.jsonadd also this newly created module with translations
- within openimis-fe_js/srcinlocales.jsadd new language like below:
      export const locales = ["es-ES","en-GB","fr-FR"]
      export const fileNamesByLang = {"es":"es", "es-ES":"es","en":"en","en-GB":"en","fr":"fr","fr-FR":"fr"}
      export default {"es":"es-ES", "es-ES": "es-ES","en":"en-GB","en-GB":"en-GB","fr":"fr-FR","fr-FR":"fr-FR"}  - type yarn buildand if success - typeyarn startand you should see this translation in your app (go to 'users' page, select user, change language into the newly provided, refresh page and you should see texts in changed language)
- if you encounter any problems by that point, run yarn load-configin the main module
- there is also possibility to overwrite particular language for example 'English' into 'Gambian English' (without changes on database level). In your new translation module in index.js (for example new module called openimis-fe-language_en_gm_js):
      import messages_en from "./translations/en.json";
      const DEFAULT_CONFIG = {
          "translations": [{ key: "en", messages: messages_en }],
      }
      export const LanguageEnGmModule = (cfg) => {
          return { ...DEFAULT_CONFIG, ...cfg };
      }- this approach overwrites default enlanguage translations intoen-gm(Gambian English) translations without adding new language on database level and without changing 'locales' in 'openimis.json' and 'locales.js' file both on assembly frontend module (openimis-fe_js).
Based on error reported on that ticket
Description of error:
- after yarn startthe page loads but no content is display
- sometimes it just keeps spinning the loader
- web console doesn't show any errors
How to solve this?
- double check if you use proper versions of backend/frontend modules (assembly and core ones)
- make sure you have the latest version of dockerized database
Conclusions:
- The reason of this error is usually using not up-to-date assembly and core modules (both backend and frontend ones)
Based on error reported on that ticket
Description of error:
- modular openIMIS deployed on server
- backend is set on port 8000, frontend is set on port 3000
- backend works fine, no errors
- it is not possible to reach both login and home page due to 400 error
- web console doesn't show any errors
How to solve this?
- double check if you use proper versions of backend/frontend modules (assembly and core ones)
- make sure you added env variables on backend side (site root/sire url)
- double check value for proxykey in package.json (IMPORTANT: be careful with this setting on production environment)
Conclusions:
- The reason of this error is usually not setting up env variables on backend side and wrong value for proxykey
If you face another issues not described in that section you could use our ticketing site. Here you can report any bugs/problems you faced during setting up openIMIS app.
To customize the appearance of your openIMIS frontend, you can define a theme and optionally a logo configuration in your module settings either on database level or django admin panel (table moduleConfiguration).
To override the default theme colors, provide a theme object under the fe-core module configuration. Below is the full structure with all supported properties:
{
  "theme": {
    "name": "defaultBlue",
    "primaryColor": "#004E96",
    "errorColor": "#801a00",
    "whiteColor": "#ffffff",
    "backgroundColor": "#e4f2ff",
    "headerColor": "#BCD4E6",
    "greyColor": "grey",
    "selectedTableRowColor": "rgba(0, 0, 0, 0.08)",
    "hoveredTableRowColor": "rgba(0, 0, 0, 0.12)",
    "toggledButtonColor": "#999999",
    "lockedBackgroundPattern": "repeating-linear-gradient(45deg, #D3D3D3 1px, #D3D3D3 1px, #fff 10px, #fff 10px)"
  }
}| Property | Description | 
|---|---|
| name | Optional name identifier for the theme | 
| primaryColor | Main brand color used in headers, buttons, text, etc. | 
| errorColor | Used to highlight errors or critical UI elements | 
| whiteColor | Used for contrasting text and background elements | 
| backgroundColor | General background color for the app | 
| headerColor | Header background color | 
| greyColor | Used for subdued UI elements (e.g., disabled text) | 
| selectedTableRowColor | Background for selected table rows | 
| hoveredTableRowColor | Background for hovered table rows | 
| toggledButtonColor | Background for toggled/active state buttons | 
| lockedBackgroundPattern | Background pattern used for locked (readonly) UI elements | 
Note: If theme is not provided, the default openIMIS theme will be used instead.
Add additional property
under fe-core configuration in moduleConfiguration. Logos can also be configured via base64-encoded images. This allows the UI to show custom branding without bundling new static files.
{
  "logo": {
    "value": "data:image/png;base64,iVBORw0KGgoAAAANSUhEU...",
    "disableTextLogo": true
  }
}Note: Supported formats: svg+xml, jpeg, png
| Property | Description | 
|---|---|
| value | Base64-encoded string of the main logo | 
| disableTextLogo | (Optional) Do not show openIMIStext next to logo:trueorfalse. By defaultfalse | 
Note: If logo.value is not provided, the default openIMIS logo will be used instead.
{
  "moduleConfigurations": [
    {
      "module": "fe-core",
      "config": "{\"theme\":{...}, \"logo\":{...}}"
    }
  ]
}This frontend project uses CRACO to customize Create React App configurations without ejecting. It also sets up a flexible proxy system for API routing during development.
- Node.js (v16+ recommended)
- Yarn
- 
Install dependencies: yarn install 
- 
Create .envfile (if it doesn't exist):API_PROXY_TARGET=http://localhost:8000 - Use http://backend:8000if you're running the backend as a Docker container.
 
- Use 
- 
Start the dev server: yarn start This will start the frontend on http://localhost:3000/frontand proxy all API requests from/apito theAPI_PROXY_TARGETdefined above.
The proxy logic is handled in src/setupProxy.js. It reads API_PROXY_TARGET from the environment to dynamically redirect API calls to the appropriate backend:
- /apiβ- $API_PROXY_TARGET
- Additional proxies (e.g. /opensearch) are configured statically inpackage.json:
"proxies": {
  "opensearch": {
    "base": "/opensearch",
    "target": "http://opensearch:5410"
  }
}craco.config.js sets:
- output.publicPathto- /front/to support deployment under sub-paths.
- DefinePluginto inject environment variables.
- Dev server historyApiFallbackand proxy behavior.
webpackConfig.output.publicPath = '/front/';- src/setupProxy.js: Middleware proxy setup
- craco.config.js: Webpack and dev server overrides
- .env: Environment-specific overrides
- Make sure the backend server is running and accessible from your frontend environment.
- Use Docker network names like http://backend:8000when both frontend and backend are running in Docker.
- Set PUBLIC_URL=/frontif needed to ensure assets load correctly.