Web SDK (Angular renderer)
FlowxProcessRenderer is a low code library designed to render UI configured via the Flowx Process Editor.
Angular project requirements
Your app MUST be created using the NG app from the @angular/cli~15 package. It also MUST use SCSS for styling.
To install the npm libraries provided by FLOWX you will need to obtain access to the private FLOWX Nexus registry. Please consult with your project DevOps.
The library uses Angular version @angular~15, npm v8.1.2 and node v16.13.2.
If you are using an older version of Angular (for example, v14), please consult the following link for update instructions:
Installing the library
Use the following command to install the renderer library and its required dependencies:
A few configurations are needed in the projects angular.json
:
- in order to successfully link the pdf viewer, add the following declaration in the assets property:
- the rendered components will use the
@flowx/ui-theme
and thepaperflow-web-components
libraries for styling. In order properly to set up styling, add the following declaration in the styles property:
Using the library
Once installed, FlxProcessModule
will be imported in the AppModule
as FlxProcessModule.forRoot({})
.
You MUST also import the dependencies of FlxProcessModule
: HttpClientModule
from @angular/common/http
and IconModule
from @flowx/ui-toolkit
.
Theming
Component theming is done through two json files (theme_tokens.json
, theme_components.json
) that need to be added in the assets folder of your project The file paths need to be passed to the FlxProcessModule.forRoot()
method through the themePaths
object.
The assets/theme/theme_tokens.json - should hold the design tokens (e.g. colors, fonts) used in the theme.
The assets/theme/theme_components.json - holds metadata used to describe component styles.
For Task Management theming is done through the ppf-theme mixin that accepts as an argument a list of colors grouped under primary, status and background
Authorization
Every request from the FLOWX renderer SDK will be made using the HttpClientModule of the client app, which means those requests will go through every interceptor you define here. This is most important to know when building the auth method as it will be the job of the client app to intercept and decorate the requests with the necessary auth info (eg. Authorziation: Bearer ...
).
It’s the responsibility of the client app to implement the authorization flow (using the OpenID Connect standard). The renderer SDK will expect to find the JWT saved in the browser localStorage object at the key named access_token.
The forRoot()
call is required in the application module where the process will be rendered. The forRoot()
method accepts a config argument where you can pass extra config info, register a custom component, service, or custom validators.
Custom components will be referenced by name when creating the template config for a user task.
Custom validators will be referenced by name (currentOrLastYear
) in the template config panel in the validators section of each generated form field.
The error that the validator returns MUST match the validator name.
The entry point of the library is the
Parameters:
Name | Description | Type | Mandatory | Default value | Example |
---|---|---|---|---|---|
baseApiUrl | Your base url | string | true | - | https://yourDomain.dev |
processApiPath | Engine API prefix | string | true | - | /onboarding |
processName | Identifies a process | string | true | - | client_identification |
processStartData | Data required to start the process | json | true | - | { "firstName": "John", "lastName": "Smith"} |
debugLogs | When set to true this will print WS messages in the console | boolean | false | false | - |
language | Language used to localize the application. | string | false | ro-RO | - |
keepState | By default all process data is reset when the process renderer component gets destroyed. Setting this to true will keep process data even if the viewport gets destroyed | boolean | false | false | - |
isDraft | When true allows starting a process in draft state. *Note that isDraft = true requires that processName be the id (number) of the process and NOT the name. | boolean | false | false | - |
legacyHttpVersion | Set this to true only for HTTP versions < 2 in order for SSE to work properly. Can be omitted otherwise. | boolean | false | false | - |
Data and actions
Custom components will be hydrated with data through the $data input observable which must be defined in the custom component class.
Component actions are always found under data
-> actionsFn
key.
Action names are configurable via the process editor.
Interacting with the process
Data from the process is communicated via Server Send Event protocol under the following keys:
Name | Description | Example | |
---|---|---|---|
Data | data updates for process model bound to default/custom components | ||
ProcessMetadata | updates about process metadata, ex: progress update, data about how to render components | ||
RunAction | instructs the UI to perform the given action |
Task management component
The flx-task-management
component is found in the FlxTaskManagementModule
. In order to have access to it, import the module where needed:
Then in the template:
Parameters:
Name | Description | Type | Default | Mandatory | Example |
---|---|---|---|---|---|
apiUrl | Endpoint where the tasks are available | string | - | true | https://yourDomain.dev/tasks |
title | Table header value | string | Activities | false | Tasks |
pollingInterval | Interval for polling task updates | number | 5000 ms | false | 10000 |
Development
If you want to start the designer app and the flx-process-renderer library in development mode (no need to recompile the lib for every change) run the following command:
When modifying the library source code and testing it inside the designer app use the following command which rebuilds the libraries, recreates the link between the library and the designer app and recompiles the designer app:
./start_with_build_lib.sh
Remember to test the final version of the code by building and bundling the renderer library to check that everything works e2e.
Trying to use this lib with npm link from another app will most probably fail. If (when) that happens, there are two alternatives that you can use:
- Use the build-and-sync.sh script, that builds the lib, removes the current build from the client app node_modules and copies they newly build lib to the node_modules dir of the client app:
NOTE: This method uses under the hood the build-and-sync.sh script from the first version and the chokidar-cli library to detect file changes.
- Use the build-and-sync:watch npm script, that builds the library and copies it to the client app’s ** node_module** directory every time a file changes:
Running the tests
ng test
Coding style tests
Always follow the Angular official coding styles.
Below you will find a Storybook which will demonstrate how components behave under different states, props, and conditions, it allows you to preview and interact with individual UI components in isolation, without the need for a full-fledged application:
Storybook
Was this page helpful?