Setup the Frontend
Installation
You can get the latest code from the Sunbird RC UI Repository https://github.com/Sunbird-RC/sunbird-rc-ui
This is an Angular 8 project, and you need to install the dependencies, and run the project.
Configuration
The application needs to be configured with the appropriate fields to be able to use it. Example configuration is provided in the src/examples
folder.
Environment Config
Key | Value |
---|---|
| Base URL for the Sunbird backend. Eg: https://registry.com/api |
| URL to the OpenAPI schema definition. This could be a HTTP path or a path to a local file Eg: https://registry.com/api/schema.json OR /assets/schema.json |
| URL to logo. This logo is displayed in the header of the UI |
Forms
The forms.json
needs to be placed in src/assets/config
. This file defines the schema for various forms used, along with the fields for each. The form rendering is based on the formly.dev library, and the forms.json is a small wrapper on top of the formly schema.
In this file forms
is an array with key/value pairs. They key is the code / slug of the form which is used to access the form. Eg: if the key for a form is employee-signup
that form can be accessed via /forms/employee-signup
. Each form definition will have the below fields -
Key | Value |
---|---|
| This is the path to the API endpoints for the entity this form handles. Eg: |
| Forms can be of 2 types. It can either be a form to create a new entity Eg: Employer, or it could be a form to submit a "sub-field" eg: work experience of an employee. For the former use |
| HTML Class applied to the form container |
| Title of form |
| Redirect URL on after form submit |
| List of fieldsets(multiple) for this form. At least one fieldset is needed |
fieldsets
Key | Value |
---|---|
| Name of the OpenAPI "Definition" to use |
| List of fields(multiple) to populate for this fieldset. If you wish to display all fields from the schema, you can skip defining each field, and use use |
fields
Key | Value |
---|---|
| Name of field (same as defined in defination of that schema) |
|
|
|
|
| Class of field |
|
|
|
|
|
Layouts
The layouts.json
is used to define how the public and private profile pages look like. For each entity in Sunbird backend, a layout file should be defined with the fields and the order in which they should display.
In this file layouts
is an array with key/value pairs. They key is the code / slug of the layout page which is used to access the form. Eg: if the key for a layout is employee-profile
that page can be accessed via /profile/employee-profile
. Each layout definition will have the below fields -
Key | Value |
---|---|
| URL Path of API |
| Title of form |
| Cards/Blocks (multiple) to populate in |
blocks
Key | Value |
---|---|
| Defination of fields from JSON Schemas in |
| Title of Card/Block |
|
|
|
|
|
|
|
|
|
|
| Array/List of fields(multiple) to populate in |
fields
Key | Value |
---|---|
| Array/list of Included Fields from response or |
| Array/list of Excluded Fields from response |
FAQs
Proxy configuration
To avoid CORS issues you can use proxy configuration. Run npm start
or ng serve --proxy-config proxy.conf.json
. For additional configuration please check proxy.conf.json
file.
Hosting the Frontend
The frontend may be hosted any of the below ways
As a container. You may create an image with the angular build files.
On a VM
In blob storage (eg: S3, with a CDN in front)
Last updated