UI Development Process
Introduction
This guide covers the end-to-end workflow for developing frontend code for Mango Automation modules. It is IDE- and OS-agnostic, though IntelliJ IDEA is the recommended IDE for Mango development.
Technology Brief
The main Mango user interface is supplied by the mangoUI module. It is a single-page AngularJS (1.x) application that can be extended by other Mango modules -- for example, modules can supply new pages and routes or provide a component for editing a particular type of data source.
Mango modules use Webpack to compile and bundle all web resources into a single JavaScript file that is loaded by the client browser.
The Mango UI relies heavily on the AngularJS Material framework and loosely adheres to the Material Design guidelines.
The UI can also be extended by supplying a user module (AngularJS module) and CSS file stored in Mango's internal file store. This approach is useful for small projects where developing a full Mango module is unnecessary.
Tools Required
Install these tools before developing Mango modules:
| Tool | Version | Download |
|---|---|---|
| Git | Latest | git-scm.com |
| Node.js | 20.x or 22.x LTS | nodejs.org |
| Yarn | 1.x (Classic) | classic.yarnpkg.com |
| Java (runtime) | JDK 17+ minimum | Azul Zulu |
| Java (build) | JDK 25 | Azul Zulu |
| Maven | 3.9.9+ | maven.apache.org |
| IntelliJ IDEA | Community or Ultimate | jetbrains.com |
We use Yarn Classic (1.x) lock files. Yarn 2+ (Berry) is not currently supported.
Code Style and Design Guidelines
JavaScript
JavaScript should be written according to the ECMAScript 6 (ES6) standard. We do not use a transpiler such as Babel. Ensure that the features you use are supported by all popular modern browsers: Chrome, Firefox, Safari (iOS and desktop), and Microsoft Edge.
Follow the Airbnb ES6 style guide with these project-specific adjustments:
| Rule | Setting |
|---|---|
| Indentation | 4 spaces (not tabs) |
| Trailing commas | Required in multiline constructs |
| Quotes | Single quotes |
| Semicolons | Required |
| Object curly spacing | No spaces ({a, b} not { a, b }) |
var keyword | Forbidden -- use const or let |
Use a linter (ESLint) in your IDE to check for errors and enforce the style guide. The ESLint configuration for the Airbnb style guide can be found here.
AngularJS
AngularJS components should use the AngularJS 1.5+ component syntax. Do not use directives for this purpose.
Code that makes REST API requests should be placed in a service. Do not make REST requests directly from a component.
Component and service names should be prefixed with ma to namespace them and prevent conflicts with other libraries.
Do:
- Leverage the
$onInit(),$onChanges(), and$onDestroy()lifecycle hooks - Use ES6 classes for component controllers
- Use
&callback bindings for outputs - Require ngModel where appropriate and implement its
render()and$setViewValue()methods - Use the
$$ngIsClassand$injectstatic getters (see the AngularJS patterns in the project CLAUDE.md for the canonical class structure)
Do not:
- Use two-way/bidirectional
=bindings
Material Design
The Mango UI loosely follows the Google Material Design guidelines, using the AngularJS Material library. Leverage components and directives from this framework whenever appropriate.
HTML
Markup should be HTML5 with AngularJS extensions.
Layouts
HTML layouts should use the AngularJS Material flex layout directives or component-specific CSS classes that apply flex layout styles.
Responsive Design
Layouts should be responsive and work on all screen sizes. Use AngularJS Material flex layout directives to achieve this.
CSS
- Prefix CSS class names with
ma-to namespace them - Scope component styles to the component element tag:
ma-my-component .ma-large-text { /* rules */ } - Do not use inline styles. Add a CSS file for each component and import it via ES6:
import './myComponent.css'; - Never use the
!importantkeyword. Use a higher-priority selector instead.
Colors
The Mango UI uses AngularJS Material to apply colors from a configurable palette (set on the "UI Settings" page). Hardcoding colors in CSS is prohibited.
Apply colors using the md-colors directive. Always use a one-time binding when the color will not change.
Localization and Internationalization
Do not hardcode English text in HTML. Place all messages in the module's classes/i18n.properties file and use the ma-tr directive to include translated messages in markup.
Use moment.js to format dates with a format string that honors the user's locale settings, for example lll LTS. There is also an AngularJS filter named maMoment for formatting dates in markup:
ng-bind="timestamp | maMoment:'format':'ll LTS'"
Cloning the Git Repositories
Git Configuration
Add the following to your global Git config:
[branch]
autosetuprebase = always
Clone Repos
Clone the Mango repositories for the modules you will be working on into a single directory (your "development home" directory):
Once cloned, switch to the branch corresponding to the version of Mango you are developing on. The main branch tracks the latest development. For specific release lines, use version branches such as 5.x.
Installing Mango
Please read the installation documentation. Unless directed to use a specific release version, download the latest nightly build from the Mango Store, which is built from the main Git branch.
Configuring mango.properties
After installation, configure your mango.properties file (located in mango-data/mango.properties) to enable development features.
Store URL
When developing on the nightly build, set the store URL to pull updates from the test store:
store.url=https://teststore.mangoautomation.net
Development Mode
Enable development mode to load web resources from your module development directory instead of from the installed module. This lets you change source files and see changes immediately on browser refresh.
development.enabled=true
development.home=/path/to/your/development/home
development.moduleDirectories=ma-dashboards
development.linkWeb=true
development.linkResources=true
development.linkClasses=true
development.loadMavenClasses=false
Configure development.moduleDirectories with a comma-separated list of repository directories inside your development home.
To limit development mode to specific modules, use the whitelist setting:
development.whitelistModules=mangoUI
- You need to give your development user permission to create symbolic links: see this guide.
- Escape backslashes in the
development.homepath, for example:C:\\Users\\YourName\\mango-dev
Effects of Development Mode
When development mode is enabled:
- Java classes and properties files are loaded from the module's development directory (
maven-target/classes) - A symlink is created from the installed module's
webdirectory to your development directory'swebfolder - You can run Webpack in your development directory and see changes on page reload
- AngularJS module files from SNAPSHOT modules are loaded with a new
?v=parameter on each page refresh, so you do not need to disable your browser cache - A button appears on the UI toolbar to clear the translation cache and reload the page
Miscellaneous Settings
Prevent Mango from opening a browser window on each start:
web.openBrowserOnStartup=false
Enable the Swagger/OpenAPI UI at http://localhost:8080/swagger-ui.html:
swagger.enabled=true
Starting Mango
Use the $MA_HOME/bin/start-mango.sh script to start Mango. See the installation documentation for details.
You should now be able to access Mango at http://localhost:8080/ (provided you have not changed the default port or HTTPS settings).
Compiling Frontend Code
Ensure the module you are working on is installed in Mango (development mode only works for installed modules).
Install Node.js dependencies in your module development directory:
yarn install --frozen-lockfile
Compile and bundle the source files from the module's web-src directory into the web directory:
yarn webpack --mode development
Alternatively, run Webpack in watch mode for automatic recompilation when source files change:
yarn webpack --mode development --watch
Refresh your browser to see updated changes.
Debugging
Compile your module's frontend code using Webpack development mode (as shown above) to enable readable source maps in your browser's developer tools. Chrome DevTools is recommended for JavaScript debugging.
When modules are built via Maven for production deployment, Webpack runs in production mode, which minifies the JavaScript and makes debugging difficult.
Browser Caching
With development mode enabled, all module resource files are loaded with a ?v= query parameter that changes on each page refresh. You should not need to clear or disable your browser cache.
However, the Mango UI installs a service worker that caches module assets. In Chrome DevTools, go to the Application panel and check Bypass for network under the Service Workers section. Note that DevTools must remain open for this setting to take effect.
Module Directory Structure
The following summarizes the general directory layout of a Mango module (may vary slightly between modules):
Paths marked with
**should not be committed to the Git repository.
| Path | Description |
|---|---|
src | Java source code |
src-test | Java test source code |
resources | Java resources included in the built .jar file |
file-resources | General resource files installed into the module directory |
api-test | Node.js/Mocha tests for the REST API |
classes | Files added to the Java classpath |
classes/i18n.properties | Root translations file (effectively en_US translations) |
** maven-target | Output directory used by Maven when building the module |
web-src | Source files for Webpack compilation (JS, CSS, HTML, images) |
web | Files served by the web server once the module is installed |
** web/angular | Output directory for Webpack bundling |
licenceTypes.xml | Module licensing information |
module.properties | Module metadata loaded by Mango |
pom.xml | Maven build configuration and Java dependencies |
RELEASE-NOTES | Release notes displayed by the store |
webpack.config.js | Webpack configuration file |
yarn.lock | Yarn lock file for NPM package versions |
package.json | NPM package information and JavaScript dependencies |
** node_modules | Installed NPM dependencies |
** node | Node.js and Yarn binaries used during Maven builds |
Creating a New Module
- Copy the default pom.xml into your new module directory.
- Edit the
pom.xmlwith your module name, artifact ID, and description. - Copy the default package.json into the module directory.
- Run
yarn install. - Run
yarn run update-package-json. - Create a
web-srcdirectory with a root.jsfile named after your module. - Create a
webpack.config.jsfile. - Run
mvn installto build the module.
Building a Complete Module Zip File
With Maven 3.9.9+ installed, build a complete module zip for installation into Mango:
mvn install -Pinstall-module
To compile frontend code in development mode during the build:
mvn install -Pinstall-module -Dwebpack.mode=development
For a full Mango build including core and all modules:
mvn install -Pcore-bundle,core-zip,install-module,maven-cache
The first build will take longer as Maven downloads all plugins and dependencies. Copy the built module zip from maven-target into $MA_HOME/web/modules and restart Mango to install it.
Related Pages
- Java Developer IDE Setup — IntelliJ IDEA setup for building Mango 5.x modules
- Browser Debugging — Debug frontend issues using Chrome Developer Tools
- User Module Setup — Lightweight alternative for adding AngularJS components without a full module build
- Custom Module Overview — Tutorial series for building a complete custom Java module
- Introduction to HTML5 Web Apps — Overview of Mango's AngularJS UI framework