Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Spell check and renamed INTTEST to Internal Test

...

Common Workplace (fælles arbejdsplads) is the shell application, and is named kam-ui. It exposes three micro frontends: care team, plandefinition plan definition and questionnaire. The Common Workplace exposes a micro frontend called Kam-pickers which contains a number of generic pickers which can be used by micro frontends loaded into the shell application kam-ui. Kam-pickers

...

Explanation

Metadata

  • Id: unique id ID for micro frontend

  • displayName: The menu item name

  • iconName: name of the icon (only support https://fonts.google.com/icons )

  • route: url URL path to the micro frontend in the shell application

  • requiredRoles: the required role to access the micro frontend

  • webComponentConfig:

    • tag: The html HTML tag for the web component

    • url: Script file needed for the micro frontend

    • exposedModule: Name for module foderation in webpack.config file

    • microFrontendName: the unique name specified in webpack.config for module federation

The shell application dynamically generate generates the navigation menu based on the content of the configuration file. Which menu items will be available to a specific user is determined by the users' context and the required roles specified for the individual micro frontends.

...

The micro frontends are as self-contained as possible. The intent was to keep the interface between the shell application and the micro frontends as small as possible to make development easier and less error-prone to changes.

It is however impossible for the shell and micro frontend to be completely seperated separated as the shell must have some knowledge about the micro frontend and vice versa. The meta datametadata, previously mentioned, is an example of the shell knowing how the micro frontend has declared its Web Component, and how it is exposed. A need also arose for having micro frontends handle events from the shell , when navigation needed to be reset on micro frontend clicks. The table below describes the event interface of the shell application kam-ui.

Event

Payload

Description

kam-mf-selected

Code Block
language
js
json
{
  microFrontendName: string;
}

Event emitted by the shell application, when a micro frontend is selected in the navbar.

kam-shell-context-changed

Code Block
languagejs
{
  userContext: {
    careTeamName: string | null;
    careTeamReference: string | null;
    organizationName: string;
    organizationReference: string;
    isCurrent: boolean;
    oioRoles: string[];
  }
}

Event emitted when the user context in the toolbar changes.

Micro frontend Context Management

...

The micro frontend must listen to the custom event “kam-is-shell-allowed-to-leave-mf”. When the micro frontend receives the event and the property microFrontendName matches the name of the micro frontend, the micro frontend must determine if the user is allowed to leave the micro frontend. The micro frontend must be able to determine if the user is for instance filling in a form(dirty form) and then ask the user if the user wants to leave the page with unsaved changes. If the user click clicks yes to leave the page a custom event must be dispatched. If the user has no unsaved changes a custom event must be sent without asking the user.

...

The shell applications routing handles the login flow and navigation to the micro frontends by the navigation menu og or direct url URL to the micro frontend like “<baseurl>/administration/plandefinition”. There is no support for deep url URL inside a micro frontend, this means that even though the micro frontend has routing internally the browser url URL will still be like this “<baseurl>/administration/plandefinition” when the user navigates in the micro frontend.

When navigating back using the browser or back button it is expected to only navigate back inside the micro frontend. By default, this is not the case, and both the micro frontend and shell are navigated back. The only way to correct the navigation in micro frontends is to block location popstate in the shell application. This comes however with the cost of disabling forward navigation in the application.

...

All micro frontends must be self-contained regarding their styling. If a micro frontend is depending on some framework using global styles, it is the developer of the micro frontend's responsibility to scope it. Below is a non-exhaustive list of approaches for scoping styling.

  • Wrapping the micro frontend in a Shadow DOM

  • Prefixing all styles. In component-based frameworks, this could be achieved by using scoped styles in the root component (exe.g. Scoped styles in Vue ).

  • Last The last resort is removing global styles programmatically using the DOM API

  • Using a framework that is not dependent and does not use global styles

...

Kam-ui is the shell application of KAM. It handles all authentication of the app and authorization to access each micro frontend. In kam-ui an , a user can select a context with roles which allow them access to specific micro frontends. The user can access micro frontends by navigating to “Administrativt” in the top toolbar and selecting a micro frontend from the left navbar.

...

To help micro frontend developers the CSP header is set to Report-Only in environments devenvcgi and the internal test environment (inttest). The browser will throw an error in the console if the CSP header is violated.

Developers of micro frontends must inform Systematic if the CSP should be updated to accommodate the needs of the micro frontend as the header will block calls (Report only on devenvcgi and inttest)

Example inttestInternal Test Environment (INTTEST)

Code Block
Content-Security-Policy 
  "default-src 'self' *.inttest.ehealth.sundhed.dk; 
  style-src 'self' *.inttest.ehealth.sundhed.dk 'unsafe-inline'; 
  script-src-elem 'self' *.inttest.ehealth.sundhed.dk; 
  connect-src 'self' *.inttest.ehealth.sundhed.dk; 
  font-src 'self' *.inttest.ehealth.sundhed.dk fonts.gstatic.com;
  img-src 'self' *.inttest.ehealth.sundhed.dk data:";

...

Using micro frontends in other applications than Common Workplace

The micro frontends is are implemented as Web Components which makes it possible to reuse them in other web applications using the Angular framework.

...

  • Angular version 12.2.16

  • Angular Material 12.2.13

    • With the css CSS class mat-typography added on the body tag in index.html

  • angular-architects/module-federation 12.5.3

  • angular-architects/module-federation-tools 12.5.3

  • Be aware of routing as described here: Routing

...

Kam-mf-plandefinition is a micro frontend for creating, editing and viewing plan definitions. A plan definition consists of nested actions that each point to an activity intended for a citizen to perform. A user can create these activities and structure them to their liking. Furthermore, they can move actions, set relationships between and timing on them. Possible activity types are:

Type

Description

Instruction

Activity for showing rich text or attaching a file or picture.

Questionnaire

Activity containing a questionnaire for the citizen to complete.

Measurement

Activity where the citizen is expected to measure something. Can have triaging rules and ranges based on that measurement. Ex. blood pressure.

Combined measurement

Activity composing multiple measurement activities. Used when a measurement device can provide multiple different measurement types.

Kam-mf-careteam

Kam-mf-careteam is a micro frontend for creating and managing care teams. A care team is used with a practitioner login to define the context in which the practitioner is working. The micro frontend allows exporting all care teams to a csv-file.

...