Completely transform the Niagara login experience with built-in responsive templates or create your own custom login screens from scratch

Readme

NiagaraMods Domo

Version 1.0 Beta #2

Domo is a module that allows you to completely customize the Niagara web login screen. Domo adds three new Login Templates to the Niagara WebService. Two of them are completely redesigned login experiences ready to go out of the box. The third allows you provide your own custom HTML, JavaScript, CSS and images to build a login screen from scratch.

Domo is currently in beta and has a limited feature set. For more information on the limitations in this version, see the Beta Notes & Roadmap section below.

Installation

Domo works on Niagara 4.6 through 4.10. 4.11+ support is coming in a future release

  1. Extract the zip file and copy the nmxdomo-rt.jar file to your Niagara modules directory.

  2. If Workbench is open, close it and relaunch.

  3. If you are using this module on a local station, restart the station using the Application Director in your Platform.

  4. If you are installing on a remote station, connect to the platform of the remote station. Then go to the Software Manager and install the nmxdomo-rt module to the remote station.

Usage

  1. Connect to your station, then open the Property Sheet of your WebService component in Config > Services

  2. Find the Login Template property, and uncheck null if it is checked.

  3. In the first dropdown of the Login Template property, select nmxdomo

  4. In the second dropdown of the Login Template property, select the template you wish to use.

  5. If you select to use the DomoUserCustom template, you will need to provide a custom login theme to use in your station file system. For more details, see the Using Custom Themes section below

Change Log

Domo Beta #2 – March 28, 2022

  • Adds support for password reset in Domo themes. The Floating Card and Left Pane themes have been updated to support this change. NiagaraMods official themes Clean and Modern have also been updated. If you want to support password reset in your custom themes, use the theme source code included in the package download as a reference.

  • Fixes a bug with mobile Safari which could prevent the login button from being clicked on custom themes

Beta Notes & Roadmap

Important notes about this version of Domo

  • 4.11+ Support - Tridium has change its login system starting in Niagara 4.11. This will require a separate build of Domo to support these stations; this build will be available in Beta 3.  

  • Supported Auth Types - the built-in Domo templates and Domo JavaScript library only support digest authentication. This is the default authentication type for Niagara users. Single Sign-on (SSO) and other mechanisms for authentication are supported in Niagara are not supported in Domo. You can write this support yourself in your theme if you are using the DomoUserCustom template and providing your own HTML and JavaScript.

  • 2FA - two-factor authentication is not supported

  • Localization - the built-in Domo templates do not support Lexicons or localization. We plan to build this support in to a future version. In the meantime, you can localize your own DomoUserCustom template using the theme files for the two built-in templates that are included with the package download.

Built-in Templates

The two built-in templates, DomoLeftPane and DomoFloatingCard provide a simple login interface with beautiful fullscreen wallpapers from Unsplash.com. Both templates are fully responsive and will look great on desktop browsers and mobile phones.

Left Pane

Provides a split login pane with a random full art background image from Unsplash. This background image will change every time a user visits the page, or you can set a custom image to be used all the time.

Floating Card

Provides a centered floating card in the middle of the screen with a full art background image from Unsplash. This background image will change every time a user visits the page, or you can set a custom image to be used all the time.

Customizing the Built-in Templates

Both built-in templates work with the two custom WebService slots that Niagara provides to specify a logo image and a CSS styles. In addition to these two slots, you can further customize the login experience with the slot list below. Just add the slot to the WebService component using the Slot Name below and set the value if one is required.

Slot Name

Type / Description

logo

baja:Ord

The default Niagara logo slot, the image at this Ord will be used as the logo on the page

loginCss

baja:Ord

The default Niagara CSS slot, the CSS file at this Ord will included in the login page. Use this to override the page styles with custom values

primaryColor

baja:String

Color used for the buttons and input boxes. If this is not set, a default color of #2d8cf0 will be used. The value can be any CSS color string including Hex, RGB, RGBA, and HSL. Note that white text will be displayed on top of this color so ensure that it will remain readable on the color you choose.

transparent

Any type

If this slot exists, the background of the left pane will be semi-transparent and the wallpaper image will show through. Note: this slot only effects the DomoLeftPane template, it will be ignored in the DomoFloatingCard template.

noUnsplash

Any type

If this slot exists, the themes will not connect to Unsplash to download a random wallpaper image. Instead, if no background image is set, the backgroundColor will be used. This option is automatically turned on if a custom wallpaper image is being used in the background slot.

unsplashSearch

baja:String

A custom search term to use when finding a random wallpaper image from Unsplash. If this slot does not exist, the search term that is used for the image search will be abstract which results in more abstract photography suitable for any station.

background

baja:Ord

Provide a File Ord to an image that will be used as the background for the page. Note that if this slot has a value, the login will no longer fetch an image from Unsplash. If this slot does not exist, or it is null or blank, Unsplash will be used or if Unsplash is disabled, the backgroundColor slot will be used.

backgroundColor

baja:String

The background color for the wallpaper area. The value can be any CSS color string including Hex, RGB, RGBA, and HSL. If this slot does not exist or is null the templates will fall back to using the primaryColor slot.

backgroundGradient

Any type

If this slot exists when a background color will be used as the wallpaper (either because Unsplash is turned off and there is no background image slot, or Unsplash has encountered an error fetching a wallpaper image), the background color will use a gradient that spans from the background color value to transparent. You can control the color behind the transparent part by setting a pageBackground slot value. The value of this slot does not matter, only that it exists in the WebService component.

pageBackground

baja:String

The background color for the entire page. Other backgrounds including backgroundColor and background images will appear on top of this. The value can be any CSS color string including Hex, RGB, RGBA, and HSL. If the slot does not exist or it is null or blank, the page's background will default to the web browser's default setting.

hideEula

Any type

If this slot exists, the End User License Agreement links below the form will be hidden.

Using Custom Themes

You can find custom themes to download on the NiagaraMods Exchange under the domo tag.

You can use your own, completely custom HTML, JavaScript, CSS, and image files to build a login page from scratch. To activate the custom page, choose the DomoUserCustom as the Login Template for the WebService and place your custom theme's files in a folder named domo in the root of your station file system at Ord file:^domo/.

For details on building a custom theme, see the Building Custom Themes section below.

Security Notes

Public/Unauthorized Access to Domo Files

When a Domo Login Template is enabled, Domo will serve files in the domo directory of your station file system publicly at the URL login?domo/filname.ext. Domo will only respond to requests for files that exist in the domo directory of your station file system. No other data will be served. Do not put a file in the domo directory unless you want it to be publicly accessible for a login screen.

Web Filtering and Outbound Firewalls

Domo connects to the server unsplash.niagaramodules.com over HTTP/S to fetch randomized wallpapers from the Unsplash API. The images are then downloaded from images.unsplash.com. Ensure that both of these hosts are accessible from your end users' networks/web browsers. This is only necessary if you wish to use Unsplash images as wallpapers. Domo does not cause your Niagara station to hit these end points, they are hit in the end-user's web browser. Domo does not issue any requests over the internet from your station.

Building Custom Themes

You can use your own, completely custom HTML, JavaScript, CSS, and image files to build a login page from scratch. To activate the custom page, choose the DomoUserCustom Login Template in the station WebService and add your custom files to a folder named domo in the root of the station file system.

This package file includes examples of the two built-in themes as well as a base template for starting a new custom theme.

Login Page (required)

The only required file for your theme is a login.hbs or login.html page. This file should exist in your station at the file:^domo/login.html or file:^domo/login.hbs ords.

Handlebars Templates

Domo uses Handlebars templates to insert data in to your page. This includes the customization slot values listed above in Customizing the Built-in Templates so you can allow users of your theme to customize it further.

  • The login file will be parsed with Handlebars even if it has a .html file extension

  • Domo does not support the use of partials, but does support Block Helpers including #if and #unless

  • Domo uses handlebars.java to parse templates, for more details on supported features, see the documentation

Template Variables

Template variables can be accessed using the standard Handlebars syntax of {{variableName}}

Variable

Description

title

String

The title of the station, typically the station name

primaryColor

String

The value of the primaryColor slot specified on the WebService component. In the built-in templates, this is used as the color for the submit button and focused elements

hasLoginCss

Boolean

True if a custom loginCss BOrd slot exists on the WebService component and successfully resolves to a file in the station file system

hasLogo

Boolean

True if a custom logo BOrd slot exists on the WebService component and successfully resolves to a file in the station file system

hasBackground

Boolean

True if the background BOrd slot exists on the WebService component and successfully resolves to a file in the station file system. You can access the background image at the url /login?image=background in your theme

backgroundColor

String

The value of the backgroundColor slot specified in the WebService component

hasGradient

Boolean

True if the backgroundGradient slot exists on the WebService component

hasPageBackground

Boolean

True if the pageBackground slot exists on the WebService component and is not null

pageBackground

String

The value of the pageBackground slot on the WebService component

transparent

Boolean

True if the transparent slot exists on the WebService component

noUnsplash

Boolean

True if the noUnsplash slot exists on the WebService component

unsplashSearch

String

The value of the unsplashSearch slot on the WebService component

hideEula

Boolean

True if the hideEula slot exists on the WebService component

hasError

Boolean

True if a login attempt was unsuccessful

username

String

The username attached to the current session

Custom Template Variables

You can expose any additional WebService slots as custom template variables by including a file named custom.slots in the domo directory. The full Ord location is file:^domo/custom.slots. This file should contain a list of slot names you wish to make available as template variables. There should be one slot name per line. The following custom.slots example file will make the customSlot and Another$20Slot variables available in the template with the same values as the slots on the WebService. Two other Boolean variables named hasCustomSlot and hasAnother$20Slot will be created that can be used to check if the slot exists from template HBS/HTML files and from JavaScript.

custom.slots Example:

customSlot
Another Slot

Note the space in the second entry Another Slot will be converted to Slot Path syntax Another$20Slot – you must use Slot Path syntax when accessing the slot from your template.

<!-- Example Usage in Template -->
<h1>
  Custom Slot is: <b>{{customSlot}}</b>
</h1>

<!-- Check if slot exists in WebService before displaying its value -->
{{#if hasAnother$20Slot}}
  <h2>
    Another Slot is: <b>{{Another$20Slot}}</b>
  </h2>
{{/if}}

To verify or find out which slots and variables are included in the template you can print out the full list in a web browser's console with the following JavaScript:

console.log($domo.config);

Supporting Files

You can access other files in the domo directory from your template's HTML/HBS file using the /login?domo/filename.ext path. For example, if you have an image named logo.png in your station at the Ord file:^domo/logo.png you could display it in your Login HTML file like this:

<img src="/login?domo/logo.png">

Only files in the domo directory can be accessed this way. These are the only files from your station made available to users who have not logged in. Make sure you do not put any file in the domo directory unless you want it to be publicly accessible.

Niagara Logo and Login CSS

You can include the standard logo file and login css file specified in the WebService slots with the standard URLs used by Niagara:

Logo - /login/logo

Example

<img src="/login/logo">

Login CSS - login/loginCss

Example

<link rel="stylesheet" href="/login/loginCss" />

User Defined Custom Background Image

You can access the custom background slot in your HTML using the /login?image=background URL.

CSS Example

.background {
  background-image: url('/login?image=background');
}

HTML Image Tag Example

<img src="/login?image=background">

Domo JavaScript Library

The Domo JavaScript Library can be utilized in your custom login pages by including the following lines in the <head> tag in your HTML before any content or other external JavaScript files are loaded.

<script type="text/javascript" src="/login/core/auth.min.js"></script>
<script type="text/javascript" src="/login?domo.js"></script>

auth.min.js

This file is part of the base Niagara login system. It provides JavaScript functions utilized by the Domo JavaScript Library to log a user in to Niagara. It must be included before domo.js and is required for it to function properly.

login?domo.js

This script provides an API to interact with Domo and the Niagara login system. The API is accessed using the global $domo variable or window.$domo.

$domo.config

The domo configuration object. This object includes JavaScript variables for all Template Variables listed above in the Template Variables section. It will also include any custom slot you've defined in the custom.slots file. For more information see Custom Template Variables above.

// Example Configuration Object

window.$domo.config = {
  title: "station",
  primaryColor: "#2d8cf0",
  hasLoginCss: false,
  hasLogo: true,
  hasBackground: false,
  backgroundColor: "#2d8cf0",
  hasGradient: false,
  hasPageBackground: false,
  pageBackground: "",
  transparent: true,
  noUnsplash: false,
  unsplashSearch: "abstract",
  hideEula: false,
  hasError: false,
  username: "admin"
}

$domo.display(selector, value)

Sets the CSS display style for a given selector.

// Hide all elements with given class
$domo.display('.class-name', 'none');

// Show element for specific ID
$domo.display('#element-id', 'block');

$domo.login(options)

Attempt to login to Niagara with the given options:

// default options
options = {
  username: null,
  password: null,
  redirect: true,
  successCallback: null,
  failCallback: null,
};

username <String>
The username submitted to Niagara login. If the value is null Domo will automatically look for an element with an id of username and attempt to use it's value as the username submitted for login.

password <String>
The password submitted to Niagara login. If the value is null Domo will automatically look for an element with an id of password and attempt to use it's value as the password submitted for login.

redirect <Boolean> or <Object>
Whether or not to redirect the user after a login attempt. If set to true, the user will be directed to the Niagara system after they've logged in or back to the login page if there is an error. If you set this to false, you should handle redirecting users manually in the success and fail callbacks.

You can pass an object if you wish handle redirects differently for success and failure. Below is an example:

redirect: {
  success: true,
  fail: false, // will be handled by callback
}

success <Function (url, response)>
Function called when a login is successful. Parameters are a URL to redirect the user to and the full response from the login service. This function may or may not be called if the redirect option is true due to the redirect happening immediately after a successful login.

fail <Function (url, error)>
Function called when a login fails. Parameters are a URL to redirect the user to and an error response from the login service. This function may or may not be called if the redirect option is true due to the redirect happening immediately after a failed login.

Login Examples

// If your input fields have 'username' and 'password' as their IDs
$domo.login();

// Using callbacks to redirect the user after additional JavaScript logic
$domo.login({
  redirect: false,
  successCallback: function(url, response) {
    alert('Login successful');
    location.href = url;
  },
  failCallback: function(url, error) {
    alert('Login error');
    location.href = url;
  },
});

// Using callbacks and only redirecting on success
$domo.login({
  redirect: {
    success: true,
    fail: false,
  },
  fail: function(url, error) {
    alert('Login error');
    location.href = url;
  },
});

Unsplash

You can use Unsplash to load in random images. To use the Domo Unsplash library include the following JavaScript after the other Domo libraries above.

<script type="text/javascript" src="/login?unsplash.js"></script>

$domo.unsplash(selectors, options, callback, fallback);

selectors <Object>
Object that specifies which elements in your HTML file will be loaded with content from Unsplash. There is a selector for the image/photo content, the author/photographer name, and author/photographer link. It is required to include author/photographer attribution when using Unsplash images.

selectors = {
  image: '.image', // img elements will have their src set, other elements will have their background-image style property set
  author: '#authorName', // Name of photographer/author
  authorLink: '#authorLink', // Anchor tag for author link, this must be an <a> element
}

options <Object>
Unsplash options to refine your random image search.

options = {
  term: $domo.config.unsplashSearch, // search term, use the config to pull from the slot on WebService
  orientation: 'portrait', // or 'landscape' or 'square'
  content_filter: 'high', // or 'low' – keeps content safe for work
  featured: true, // or false, when true only shows featured photos
};

callback <Function (image)>
Callback function called when the API has completed. image will be null if there was an error loading the data. If the call was successful, image will be an array containing a single object with Unsplash image data.

fallback <String> or <Object> 

Object or string specifying a fallback value if the API call is unsuccessful. If this value is a string, the string will be used to set the background-color of any element matching the selectors.image selector. If fallback is an object, fallback.color will be used. You can also specify fallback.gradient = true to use fallback.color in a gradient fading to transparent.

// Fallback color with gradient example
fallback = {
  color: #ff0000, // red
  gradient: true,
}

Unsplash Example

HTML

<script type="text/javascript" src="/login?unsplash.js"></script>
<div class="background" />
<div class="author-container">
  Photo by
  <a href="#" class="author-link"><span class="author-name" /></a>
  via <a href="https://unsplash.com">Unsplash</a>
</div>

JAVASCRIPT

var selectors = {
  image: '.background',
  author: '.author-name',
  authorLink: '.author-link',
};
var options = {
  term: $domo.config.unsplashSearch,
  orientation: 'landscape',
  content_filter: 'high',
  featured: true,
};
var callback = function(image) {
  // Display author elements after image has loaded
  if (image && image.user) {
    $domo.display('.author-container', 'block');
  }
};
$domo.unsplash(selectors, options, callback, {
  gradient: $domo.config.hasGradient,
  color: $domo.config.backgroundColor,
});

Copyright 2020 NiagaraMods

Load Comments (51)

Completely transform the Niagara login experience with built-in responsive templates or create your own custom login screens from scratch

Watchers
21
Stars
23
12,830 views • 1,787 download
Package Details

Direct Link

Last Updated

Mar 31

Compatability

Niagara 4 Only