Customizing the ZentriOS Web App

The ZentriOS Web App demonstrates the full capability of the ZentriOS HTTP RESTful API. See ZentriOS Web App. The layout and operation of the web app can be 100% customized to suit your application and your business.

The following simple examples show how to re-style the original ZentriOS styling to match the style of another brand.

If this layout or style does not suit your requirements, the entire web application can be replaced simply by modifying the root file of the ZentriOS webserver with http.server.root_filename.

The Web App Development System

The Web App development system provides a rapid edit-build-test cycle, using a local Web server on the development test machine.

The diagrams below show how the Web App development system works, and how it differs from the Web App production system.

In the development system, the test HTTP server serves the Web App from the development file system, and requires CORS to make REST requests to the ZentriOS HTTP server, in order to run ZentriOS commands.

The Web App Production System

In the production system, the ZentriOS HTTP server serves the Web App from the ZentriOS device file system, and REST requests to the ZentriOS device are made to the same origin.

Set Up and Prerequisites

Obtain a copy of the ZentriOS Web App development system from

In the following it is assumed that your working copy is in the directory /ZentriOSWebApp.

Web App Languages and Libraries

The ZentriOS Web App development system uses Jade templates and the Less CSS pre-processing language.

For more information on Jade templates, see Note that Jade has been renamed Pug due to trademark issues.

You can, if you prefer, use traditional HTML and CSS for development. See the /ZentriOSWebApp/ file for details.

The ZentriOS Web App uses the following JavaScript libraries:

The style modifications described in this tutorial can be made without detailed knowledge of JavaScript, CSS or Jade.

However to make advanced modifications to the ZentriOS Web App, familiarity with these languages and frameworks is recommended.

Setting up the ZentriOS Web App Development Environment

The ZentriOS WebApp development system uses Node.js, Grunt and Bower for package management and build automation. These tools are free.

To set up the ZentriOS Web App development system, follow the /ZentriOSWebApp/ instructions, available on github and in the top level directory of the working copy.

This involves downloading and installing Node.js, then using the node package manager, npm, to install Bower (front end package manager) and Grunt (task runner). Then run npm install and bower install from a command prompt in the /ZentriOSWebApp directory.

Setting up the ZentriOS device

The Web App development system runs a server at http://localhost:5002, on the machine on which the build system is running.

The Web App development system communicates with a ZentriOS device on the same network. The module needs to run the HTTP server, and Cross Origin Resource Sharing (CORS) must be enabled for the development host domain. The simplest way is to enable CORS for all domains.

Open a ZentriOS Terminal and issue the following ZentriOS command sequence on the device:

ZentriOS CommandsDescription

set wlan.ssid               <NETWORK NAME>
set wlan.passkey            <NETWORK PASSWORD>
set wlan.auto_join.enabled  1
set http.server.enabled     1
set               mymodule
set mdns.enabled            1
set http.server.cors_origin *

Set your Wi-Fi network name
Set your Wi-Fi network password
Enable WLAN auto join
Enable HTTP server
Set mDNS name
Enable mDNS
Enable CORS for all

After rebooting, the module ZentriOS terminal displays output similar to:

ZentriOS-, Built:2015-02-02 20:23:14 for AMW006.4, Board:AMW006-E03.2
[Associating to Zentri]
> Security type from probe: WPA2-AES
Obtaining IPv4 address via DHCP
IPv4 address:
Starting mDNS
mDNS domain: mymodule.local
HTTP and REST API server listening on port: 80

Configuring the Module and Development Host Addresses

The Web App development system needs the IP address or name of both the ZentriOS device and the development host.

The ZentriOS device address allows the HTTP RESTful API calls to the module from the development host Web server test Web App.

The development host address allows deployment of the changed web app files to the module from the localhost development Web server.

Open the file /ZentriOSWebApp/config.json and set the addresses. For example:

  "device": "mymodule",
  "localIP": "",
  "port": "5002"

You can also change the development Web server port if desired.

Building the Web App and Running the Test Server

To build the Web App, at a command prompt, in the /ZentriOSWebApp directory, issue the command: grunt

Grunt runs tasks and displays output accordingly, similar to:

Running "build" task
other tasks
Running "less:build" (less) task
File out/webapp/ZentriOS.css created: 428.36 kB → 420.99 kB

Running "jade:build" (jade) task
File ./out/index.html created.
File ./out/webapp/unauthorized.html created.

Running "compress:build" (compress) task
Created out/webapp/ZentriOS.js.gz (64.6 kB)
Created out/webapp/ZentriOS.css.gz (151.3 kB)

Running "server" task
Web server running at http://localhost:5002.

The "server" task continues until you halt it. While it is running you can view the test Web App Page.

To halt the "server" task and grunt execution, type Ctrl-C.

Opening the Test Web App Page

While the "server" task is running, in a web browser, open http://localhost:5002.

The Zentri logo appears at the top left corner of the ZentriOS Web App. You can change this to a logo of your choice.

The logo is specified in the file /ZentriOSWebApp/public/less/logo.less/.

It is set up as a background image for the .logo css class.

The first lines of the logo.less file are as follows:

.logo {
  height: 100px;
  // background-image: url('logo.png');
  background-image: url('data:image/svg+xml;...

In the unmodified logo.less file partially shown above, the logo image is created with an inline svg file specified with a data url.

Logo Image File

To substitute your own logo image, in logo.less, uncomment the line:

 // background-image: url('logo.png');

and comment out the line that begins:

background-image: url('data:image/svg+xml;

Place your own logo image file in the directory /ZentriOSWebApp/out/webapp/. Stylesheet relative URLs are determined relative to the /ZentriOSWebApp/out/ZentriOS.css file, which is the product created from the various /ZentriOSWebApp/public/less/*.less/ files during the build process.

Replace the filename 'logo.png' with the name of your substitute logo file. For example:

background-image: url('sdc_logo.png');

Logo Dimensions and Aspect Ratio

The logo dimensions are by default: height:100px; width:280px;

Create a logo of the specified proportions to fit into the available space, or modify the dimensions in the logo.less file if you prefer.

If your logo has a different aspect ratio, you can leave the width of 280px unchanged and calculate a new height as follows:

new_height = my_logo_height*(my_logo_width/280)

Set the new height in the logo.less .logo class height parameter. For example,

.logo {
  height: 69px;

Logo Background Color

You can change the logo background-color parameter in the logo.less .logo class.

To allow the background of the navigation pane (div.nav element) to show through, remove the background-color style setting. For example:

.logo {
  height: 69px;
  //background-color: #333;

To see the results of any change, rebuild the web app: stop the "server" task and grunt if it is running (Ctrl-C) and run grunt again. Then refresh the Web App page in your web browser.

In the default ZentriOS Web App, the logo links to the site.

The link from the logo is specified in the jade template for the index.html file, /ZentriOSWebApp/public/views/index.jade

Open the index.jade file and locate the following lines:

      a.wlan(href="//", data-bypass, target="_blank")

To change the logo link, change the href attribute value. For example:

      a.wlan(href="//", data-bypass, target="_blank")

Jade templates determine structure from indentation, so be careful not to alter the indentation.

To see the change, run grunt to rebuild the Web App, and refresh the Test Web App page.

For more information on Jade templates, see Note that Jade has been renamed Pug due to trademark issues.

Changing Styles

The styles of the ZentriOS Web App are determined by /ZentriOSWebApp/out/ZentriOS.css. This is built from the /ZentriOSWebApp/public/less/ files.

To change styles, first identify the css class to be altered. You can use your web browser developer tools to identify css classes associated with elements.

Then modify the *.less file that defines the css class definition.

For example, the navigation menu background (div.nav element) is determined by the .nav css class, which is defined in app.less.

 .nav {
    .gradient(@nav-light, @nav-dark);

The Less variables @nav-light and @nav-dark are defined in variables.less, included at the top of the app.less file:

@import "variables.less";

In variables.less, change the variables as desired, e.g.

//@nav-light: #3e3c3d;
@nav-light: #0db8d3;
//@nav-dark: #2d2c2d;
@nav-dark: #0881b6;

The highlights and shadows of the menu items are also set in variables.less as @nav-highlight and @nav-shadow. You can define a Less variable to have the value of another defined Less variable. For example:

//@nav-highlight: @dark;
@nav-highlight: @nav-dark;
//@nav-shadow: @darkest;
@nav-shadow: @nav-light;

To see the change, run grunt to rebuild the Web App, and refresh the Test Web App page.

Changing Features

Each ZentriOS Web App feature corresponds to a Backbone.js view.

Each view corresponds to a menu item in the main navigation menu, defined in app.js, and to a JavaScript view definition file in the /ZentriOSWebApp/public/js/views folder.

For example, the "Cloud Services" menu item corresponds to the 'cloud' element in the app.js definition of the appViews array:

var appViews = [
      {el: 'cloud',  nav: 'Cloud Services',  view: App.Views.Cloud, modes: ['wlan']}

The "Cloud Services" feature is also supported by the view definition file /ZentriOSWebApp/public/js/views/cloud.js.

Removing a Feature

To remove a feature, delete the corresponding appViews array element and the corresponding JavaScript view definition file.

For example, to remove the "Cloud Services" feature:

To see the change, run grunt to rebuild the Web App, and refresh the Test Web App page.

Adding a Feature

To add a feature, add a corresponding element to the appViews array, and add a view to the /ZentriOSWebApp/public/js/views/ folder.

For example, to add a simple page called "My Feature", add the following element to the appViews array:

  {el: 'myfeature',  nav: 'My Feature', view: App.Views.MyFeature, modes: ['wlan']},

Ensure that the array syntax is maintained correctly.

The parameters are as follows:

Download the myfeature.js file and add it to the /ZentriOSWebApp/public/js/views/ folder. This is a minimal view that displays some text.

To see the change, run grunt to rebuild the Web App, and refresh the Test Web App page.

Deploying the Modified Web App to the ZentriOS device

Ensure that the module and development host addresses are correctly configured. See Configuring the Module and Development Host Addresses above.

Ensure that the grunt "server" task is running the development test Web server. To do this, run grunt at the command prompt.

At a separate command prompt, run:

grunt deploy

In the background, the Web App development system runs the http_download command, on the ZentriOS device, to download files from the development Web server to the module.

You may also need to download other files, such as your logo file. You can do this in a ZentriOS Terminal on the module, using the http_download command. The files must be in the /ZentriOSWebApp/out/ folder. For example, if the development host IP address is

hdo webapp/sdc_logo.png

When deployment is complete, you can open the modified Web App directly from the module. For example, if mDNS is used as described above, open: http://mymodule.local

The Web App operates as shown in the Web App Production System diagram in The Web App Development System above.

Change Log

ModifiedChangesZentriOS Version