Options
All
  • Public
  • Public/Protected
  • All
Menu

Module ui-builder

Library for creating dynamic UI extensions for Cisco Webex Devices.

This means you don't need to know or deal with the XML syntax for UI extensions.

An extension (ui panel, action button or web app) is typically constructed by creating a tree of nodes. A node can be a panel, a page, a row, a slider etc. A node has attributes (type, name, color, text, ...), and most nodes types can also have child nodes.

The library will validate the attributes (a slider cannot have a name) and the children type (eg a row can only be added to a page, not a panel).

Each node type has, for convenience, a method that creates this node. Eg this is how we construct a page with two empty rows:

const { Page, Row } = require('./ui-builder');
const attributes = { name: 'My page', pageId: 'mypage' };
const children = [Row(), Row()];
const page = Page(attributes, children);

// or for short:
const page = Page({ name: 'My page', pageId: 'mypage' }, [Row(), Row()]);

To save an extension to the video device, a panel / action button / web app must also be wrapped in a Config object. Here are 3 full examples:

The 3 extensions supported: Action button, panel and web app

Example - Create an action button:

const ui = require('./ui');
const { Config, ActionButton } = require('./ui-builder');

// Create an action button for calling helpdesk
const actionButton = Config({}, [
  ActionButton({
   name: 'HelpDesk', panelId: 'helpdesk', icon: 'Helpdesk', color: '#003399',
  })
]);
ui.panelSave('helpdesk', actionButton);

If you do not want to use the ui lib (just the ui-builder), you can replace the last line with:

const xml = actionButton.toString();
xapi.Command.UserInterfae.Extensions.Panel.Save({ PanelId: 'helpdesk' }, xml);

Example - Create a panel:

const ui = require('./ui');
const {
  Config, Panel, Page, Row, ToggleButton, Slider, GroupButton
} = require('./ui-builder');

// Create a panel for controlling lights in the room
const panel = Config({}, [
  Panel({ name: 'Lights', icon: 'Lightbulb', color: 'orange' }, [
    Page({ name: 'Lights' }, [
      Row({ text: 'Main lights' }, [
        Slider({ widgetId: 'lights-toggle' }),
        ToggleButton({ widgetId: 'lights-slider' }),
     ]),
     Row({ text: 'Color' }, [
       GroupButton({
         widgetId: 'lights-colors',
         buttons: { warm: 'Warm', medium: 'Medium', cold: 'Cold' },
       })
     ])
   ]),
 ])
]);

 ui.panelSave('lights', panel);

// The node structure:
// Config
//   Panel
//     Page
//       Row
//         Slider
//         ToggleButton
//       Row
//         GroupButton
Result of running the code above

Example - create a web app:

const ui = require('./ui');
const { Config, WebApp } = require('./ui-builder');

// Create a web app link to YouTube
const webApp = Config({}, WebApp({ name: 'YouTube', url: 'https://youtube.com' }));
ui.panelSave('youtube', webApp);

Index

Type aliases

ActionButtonAttributes

ActionButtonAttributes: PanelAttributes

Availability

Availability: "Home" | "InCall" | "StatusBar" | "Never"

ButtonIcon

ButtonIcon: "arrow_down|arrow_left|arrow_right|arrow_up|audio_minus|audio_plus|back|blue|eject|end|fast_bw|fast_fw|green|help|home|list|mic|mic_muted|minus|pause|phone|play|play_pause|plus|plus|power|record|red|skip_bw|skip_fw|speaker|speaker_muted|stop|video|video_muted|volume_muted|yellow|zoom_in|zoom_out"

Color

Color: string

Color can be specified as name (blue, pink, ...), on hexidecimal format (#aa00cc) or alpha hex (#33ffffff, transparent white)

NodeActionButton

NodeActionButton: Node

As created by ActionButton

NodeConfig

NodeConfig: Node

As created by Config

NodeExtension

The general of type of extension, this typically appears on the homescreen as a button

NodePage

NodePage: Node

As created by Page

NodePanel

NodePanel: Node

As created by Panel

NodeRow

NodeRow: Node

As created by Row

NodeWebApp

NodeWebApp: Node

As created by WebApp

PanelIcon

PanelIcon: "Blinds|Briefing|Camera|Concierge|Disc|Handset|Help|Helpdesk|Home|Hvac|Info|Input|Language|Laptop|Lightbulb|Media|Microphone|Power|Proximity|Record|Sliders|Tv"

WidgetSize

WidgetSize: 1 | 2 | 3 | 4

Number of columns that the widget taks up. Each row has maximum 4 columns.

Functions

ActionButton

  • An action button is located on the home screen and can be programmed to do an action when the user presses it. Unlike a panel (button), it does not automatically open anything when pressed.

    Parameters

    Returns NodeActionButton

Button

Config

DirectionalPad

  • DirectionalPad(attributes: { text?: string; widgetId: string }): Widget
  • A 4-way directional pad + center button. The text of the center button can be specified.

    Parameters

    • attributes: { text?: string; widgetId: string }
      • Optional text?: string
      • widgetId: string

    Returns Widget

GroupButton

  • GroupButton(attributes: { buttons: object; widgetId: string }): Widget
  • Create group button, where the user can select one of several choices You can programatically select which button is selected by setting the widget value. Example:

    const group = GroupButton({
      widgetId: 'my-colors',
      buttons: {
        green: 'Green',
        red: 'Red',
        blue: 'Blue',
      }
    })
    

    Parameters

    • attributes: { buttons: object; widgetId: string }
      • buttons: object
      • widgetId: string

    Returns Widget

Page

Panel

Row

  • A row is contained in a page, and can contain multiple widgets. The widgets are laid of horizontally. Each row contains 4 columns, if the widgets take up more than that they will wrap to the next line (but same row).

    Parameters

    Returns NodeRow

Slider

  • A slider / scrollbar. The range is fixed from 0-255, you might need to map this to your own scale. See the ui lib for a handy scale function. You can programatically set the scroll position by setting the widget value.

    Parameters

    Returns Widget

Spacer

  • An invisible widget that takes up space, so you can create custom layouts with gaps if you need it.

    Parameters

    Returns Widget

Spinner

  • Spinner(attributes: { size?: WidgetSize; style?: "vertical" | "horizontal" | "plusminus"; widgetId: string }): Widget
  • A widget that lefts the user select next/previous or up/down. You can programatically update the text in the middle of the spinner by setting the widget value

    Parameters

    • attributes: { size?: WidgetSize; style?: "vertical" | "horizontal" | "plusminus"; widgetId: string }
      • Optional size?: WidgetSize
      • Optional style?: "vertical" | "horizontal" | "plusminus"
      • widgetId: string

    Returns Widget

Text

  • Text(attributes: { align?: "left" | "right" | "center"; fontSize?: "small" | "normal"; size?: WidgetSize; text?: string; widgetId: string }): Widget
  • A simple text label. Change the text by setting the value of the widget.

    Parameters

    • attributes: { align?: "left" | "right" | "center"; fontSize?: "small" | "normal"; size?: WidgetSize; text?: string; widgetId: string }
      • Optional align?: "left" | "right" | "center"
      • Optional fontSize?: "small" | "normal"
      • Optional size?: WidgetSize
      • Optional text?: string
      • widgetId: string

    Returns Widget

ToggleButton

  • ToggleButton(attributes: { widgetId: string }): Widget
  • An on/off mode button. You can programatically set the mode by setting widget value to 'on' or 'off'.

    Parameters

    • attributes: { widgetId: string }
      • widgetId: string

    Returns Widget

WebApp

  • A web app is basically a url shortcut that can open a full screen web page on the device.

    The web page is opened when the user presses the shortcut.

    Parameters

    Returns NodeWebApp

Generated using TypeDoc