Child pages
  • Widgets
Skip to end of metadata
Go to start of metadata

Widgets are designed to be used on Dashboards.

Enterprise users have complete freedom to create, update and delete widgets as required.

 

Creating

When creating a widget, if you select the 'Advanced' button you will have the ability to upload your own custom SQL.

The SELECT section of your SQL must contain fully qualified columns and specify certain columns.

Pie charts must return name or my_name, description or my_description and count.

Line charts must return date or my_date, description or my_description and count.
 

The WHERE section of your SQL must contain WHERE @filter so Open-AudIT knows to restrict your query to the appropriate Orgs.

SQL not containing this condition will result in the widget failing to be executed.

The SQL cannot contain WHERE @filter OR. That SQL will not be executed, however WHERE @filter AND queries are allowed.

An example widget SQL showing devices counted per location.

More elaborate SQL can used to group attributes within a range. Below shows the SQL for devices not seen in a pie chart grouped by last seen date ranges.


Database Schema

The schema for the database is below. It can also be found in the application is the user has database::read permission by going to menu: Manage -> Database -> List Database, then clicking on the "widgets" table.

CREATE TABLE `widgets` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL DEFAULT '',
  `org_id` int(10) unsigned NOT NULL DEFAULT '0',
  `description` text NOT NULL,
  `type` enum('line','pie','') DEFAULT 'line',
  `table` varchar(50) NOT NULL DEFAULT '',
  `primary` varchar(50) NOT NULL DEFAULT '',
  `secondary` varchar(50) NOT NULL DEFAULT '',
  `ternary` varchar(50) NOT NULL DEFAULT '',
  `dataset_title` varchar(200) NOT NULL DEFAULT '',
  `group_by` varchar(50) NOT NULL DEFAULT '',
  `where` text NOT NULL,
  `limit` smallint signed NOT NULL DEFAULT '0',
  `options` text NOT NULL,
  `sql` text NOT NULL,
  `link` text NOT NULL,
  `edited_by` varchar(200) NOT NULL DEFAULT '',
  `edited_date` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

API / Web Access

You can access the /widgets collection using the normal Open-AudIT JSON based API. Just like any other collection (assuming your an Enterprise user). Please see the API documentation for further details.

Access is provided as part of a roles permissions. Widgets is a standard resource and can have create, read, update, delete and execute permissions.

The API routes below are usable from both a JSON Restful API and the web interface. The Web application routes are specifically designed to be called from the web interface (a browser).

API Routes

Request Method
ID
Action
Resulting Function
Permission Required
URL Example
Notes
Example Response
GETn collectionwidgets::read/widgetsReturns a list of widgets. 
POSTn createwidgets::create/widgetsInsert a new widgets entry. 
GETy readwidgets::read/widgets/{id}Returns a widgets details. 
PATCHy updatewidgets::update/widgets/{id}Update the details of a widgets entry. 
DELETEy deletewidgets::delete/widgets/{id}Delete a widgets entry. 
EXECUTEyexecuteexecutewidgets::read/widgets/{id}/executeExecute a widget and return the resulting dataset. 

Web Application Routes

 

Request Method
ID
Action
Resulting Function
Permission Required
URL Example
Notes
GETncreatecreate_formwidgets::create/widgets/createDisplays a standard web form for submission to POST /widgets.
GETyupdateupdate_formwidgets::update/widgets/{id}/updateShow the widgets details with the option to update details using PATCH to /widgets/{id}