Spanish Total.js
Deutsch
Dokumentation Für KI-Agenten
Inhalt

Widget reference

The keys and functions of a widget file, in the server part and in the browser part.

.md Website

Diese Seite ist noch nicht übersetzt. Du liest das Original.

Auf dieser Seite

A widget file sets keys on exports in two places: in <script total> on the server, and in the <script> of <body> in the browser. See Custom widgets for a whole file.

Entries of type property are keys you set. Entries of type event are functions you define and Dashboard calls. Entries of type method are functions that Dashboard gives you.

API

property

exports.name = 'Total';

The name of the widget in the Widgets window and the first title of a new widget.

Set it in <script total>.

property

exports.icon = 'ti ti-calculator';

The icon of the widget in the Widgets window.

A Total.js icon class. Set it in <script total>.

property

exports.color = '#34A853';

The colour of the icon in the Widgets window.

Set it in <script total>.

property

exports.config = { dataset: [], interval: 0 };

The settings of a new widget.

Set it in <script total>. The settings form edits these keys, and exports.make receives them as config.

property

exports.hidden = true;

Keeps the widget out of the Widgets window.

Use it for a file that only adds a data source. Set it in <script total>.

event

exports.install = function(dashboard) {}

Runs on the server when the widget is loaded.
ParameterTypBeschreibung
dashboard Object The dashboard on the server. See Data sources.

Register data sources here with dashboard.source().

event

exports.uninstall = function(dashboard) {}

Runs on the server before the widget is replaced or removed.
ParameterTypBeschreibung
dashboard Object The dashboard on the server.

Remove here what exports.install registered, for example with dashboard.source(name, null).

property

exports.offset = { lg: { width: 3, height: 2 }, md: { width: 4, height: 3 }, xs: { width: 6, height: 3 } };

The size of a new widget on the grid, for large, medium and extra small screens.

Width and height are in cells of the grid. The grid is 12 cells wide. Set it in the browser part.

property

exports.actions = { move: true, remove: true, resize: true, resizeX: true, resizeY: true, settings: true };

What people may do with the widget on the dashboard.

move lets them drag it, resize, resizeX and resizeY let them resize it, remove shows the bin icon and settings shows the gear icon. Set it in the browser part.

property

exports.header = true;

Shows the title bar of the widget.

Set it in the browser part.

property

exports.import = ['https://cdnjs.cloudflare.com/ajax/libs/apexcharts/3.54.1/apexcharts.min.js'];

Scripts and style sheets that the widget needs.

Dashboard loads each address once, before it draws the dashboard. Set it in the browser part.

event

exports.make = function(instance, config, element) {}

Draws one widget on the dashboard.
ParameterTypBeschreibung
instance Object The widget on the dashboard.
config Object The settings of the widget.
element jQuery The element to draw into.

Dashboard calls it for each widget of this type. Define the handlers of instance here and draw the first content.

method

instance.dataset(item, callback)

Loads the chart data of one entry of the Dataset setting.
ParameterTypBeschreibung
item Object One entry of config.dataset.
callback Function function(response) with the list of series.

The callback receives a list of series. Each series has id, name, icon, color, format, decimals and data, a list of points with x and y. See Chart data.

Load the first report of the settings
instance.dataset(config.dataset[0], function(response) {
	for (var serie of response)
		console.log(serie.name, serie.data.length);
});
event

instance.configure = function() {}

Runs after someone saves the settings of the widget.

Reload the data here, because config now holds the new settings.

event

instance.service = function(counter) {}

Runs every second while the dashboard is open.
ParameterTypBeschreibung
counter Number The number of seconds since the dashboard opened.

Use it for a refresh interval: reload when counter % config.interval === 0.

Hergestellt in Europa