_webinterface_add_routes_

From Yombo
< docs‎ | hooks
Jump to: navigation, search
webinterface_add_routes
Hook name _webinterface_add_routes_
Status Active
Hook source type Library
Stop on exception No
Commonly used Yes
Implemented by web interface

Summary

Allows libraries and module to add web interface routes (pages).

Details

Used to provide a way to add additional pages to the web interface.

KWargs

None.

Expects

Two lists can be returned:

  1. nav_side - A list of dictionaries:
    • label1 - Top level label. Ex: 'Device Tools'
    • label2 - Select level laberl. Ex: 'NEST'
    • priority1 - Placement of label1 within the nav list. Ex: None, 15000
    • priority2 - Placement of label1 within the select level nav list. Ex: None, 15000
    • icon - Font awesome icon. Ex: 'fa fa-thermometer-three-quarters fa-fw',
    • url - Url to use. Ex: /tools/module_nest
    • tooltip - Text to display on mouse over.
    • opmode When to display this link. Either 'run', 'config' or all. Ex: run
  2. routes - A list of callables that add routes. See below for example.


For basic route callable example: See home.py. The callable within home.py would be: route_home

 1 def _webinterface_add_routes_(self, **kwargs):
 2     """
 3     Adds a configuration block to the web interface. This allows users to view their nest account for
 4     thermostat ID's which they c--an copy to the device setup page.
 5     :param kwargs:
 6     :return:
 7     """
 8     return {
 9         'nav_side': [
10             {
11                 'label1': 'Presence',
12                 'label2': 'Presence',
13                 'priority1': 500,
14                 'priority2': 100,
15                 'icon': 'fa fa-info fa-fw',
16                 'url': '/tools/module_presence',
17                 'tooltip': '',
18                 'opmode': 'run',
19             },
20         ],
21         'routes': [
22             module_presence_routes,
23         ],
24     }
This page was last edited on 15 September 2018.