Это перевод страницы документации с английского языка. Помогите нам сделать его лучше.

manifest.json

Каждому модулю необходим файл manifest.json. Файл должен располагаться в главной директории модуля (например, zabbix/ui/modules/module_name/manifest.json).

Как необходимый минимум, файл manifest.json должен содержать следующие поля:

{
           "manifest_version": 2.0,
           "id": "my_ip_address",
           "name": "My IP Address",
           "namespace": "MyIPAddress",
           "version": "1.0"
       }

Параметры, поддерживаемые manifest.json (нажмите на параметр для более подробной информации):

Параметр Описание Обязателен
manifest_version Версия манифеста модуля. Да
id Уникальный ID модуля.
name Имя модуля, которое будет отображаться в разделе Администрирование.
namespace Пространство имён PHP для классов модуля.
version Версия модуля.
type Тип модуля. Для виджетов необходимо указать widget Да для виджетов, для остальных нет
widget Конфигурация виджета. Используется только для виджетов.
actions Действия для регистрации модуля.
assets Стили CSS и файлы JavaScript, которые необходимо включить. Нет
author Автор модуля.
config Значения по умолчанию для пользовательских параметров модуля.
description Описание модуля.
url Ссылка на описание модуля.

manifest_version

Версия манифеста модуля. На данный момент поддерживается версия 2.0. Тип: Double

Пример:

"manifest_version": 2.0

id

Идентификатор модуля. Должен быть уникальным. Чтобы избежать конфликта имён в будущем, рекомендуется использовать для модулей префикс (имя автора или название компании, или любой другой). Например, если модуль является примером для уроков и имя модуля «My module», то идентификатор будет «example_my_module».

Тип: String

Пример:

"id": "example_my_module"

name

Имя модуля, которое будет отображаться в секторе Администрирование.

Тип: String

Пример

"name": "My module"

namespace

Пространство имён PHP для классов модулей

Тип: String

Пример:

"namespace": "ClockWidget"

version

Версия модуля. Версия будет отображаться в секторе Администрирование.

Тип: String

Пример:

"version": "1.0"

type

Type of the module. Required for widgets and must equal "widget".

Type: String

Default: "module"

Example:

"type": "widget"

actions

Actions to register with the module. Defining class object key for each action is required, other action keys are optional.

Type: Object

Supported object keys if type is module:

  • write.your.action.name (object) - action name, should be written in lowercase [a-z], separating words with dots. Supports the keys:
    • class (string; required) - action class name.
    • layout (string) - action layout. Supported values: layout.json, layout.htmlpage (default), null.
    • view (string) - action view.

Example:

"actions": {
           "module.example.list": {
               "class": "ExampleList",
               "view": "example.list",
               "layout": "layout.htmlpage"
               }
           }

Supported object keys if type is widget:

  • widget.{id}.view (object) - file and class name for widget view. Replace {id} with the widget's id value (for example, widget.example_clock.view). Supports the keys:
    • class (string; required) - action class name for widget view mode to extend the default CControllerDashboardWidgetView class. The class source file must be located in the actions directory.
    • view (string) - widget view. Must be located in the views directory. If the view file is widget.view.php, which is expected by default, this parameter maybe omitted. If using a different name, specify it here.
  • widget.{id}.edit (object) - file name for widget configuration view. Replace {id} with the widget's id value (for example, widget.example_clock.edit). Supports the keys:
    • class (string; required) - action class name for widget configuration view mode. The class source file must be located in the actions directory.
    • view (string) - widget configuration view. Must be located in the views directory. If the view file is widget.edit.php, which is expected by default, this parameter maybe omitted. If using a different name, specify it here.

Example:

"actions": {
           "widget.tophosts.view": {
               "class": "WidgetView"
           },
           "widget.tophosts.column.edit": {
               "class": "ColumnEdit",
               "view": "column.edit",
               "layout": "layout.json"
           }
       }

assets

CSS styles and JavaScript files to include.

Type: Object

Supported object keys:

  • css (array) - CSS files to include. The files must be located in the assets/css.
  • js (array) - JavaScript files to include. The files must be located in the assets/js.

Example:

"assets": {
           "css": ["widget.css"],
           "js": ["widget.js"]
       }

author

Module author. The author will be displayed in the Administration section.

Type: String

Example:

"author": "John Smith"

config

Default values for the module options. The object may contain any custom keys. If specified, these values will be written into the database during module registration. New variables added later will be written upon the first call. Afterwards, the variable values can only be changed directly in the database.

Type: Object

Example:

"config": {
           "username": "Admin",
           "password": "",
           "auth_url": "https://example.com/auth"
       }

description

Module description.

Type: String

Example:

"description": "This is a clock widget."

widget

Widget configuration. Used, if type is set to widget.

Type: Object

Supported object keys:

  • name (string) - used in the widget list and as default header. If empty, "name" parameter from the module will be used.

  • template_support (boolean) - determines whether the widget should be available in template dashboards. Supported values: true, false (default).

  • size (object) - default widget dimensions. Supports keys:

    • width (integer) - default widget width.
    • height (integer) - default widget height.
  • form_class (string) - class with widget fields form. Must be located in the includes directory. If the class is WidgetForm.php, which is expected by default, this parameter maybe omitted. If using a different name, specify it here.

  • js_class (string) - name of a JavaScript class for widget view mode to extend the default CWidget class. The class will be loaded with the dashboard. The class source file must be located in the assets/js directory. See also: assets.

  • use_time_selector (boolean) - determines whether the widget requires dashboard time selector. Supported values: true, false (default).

  • refresh_rate (integer) - widget refresh rate in seconds (default: 60).

Example:

"widget": {
           "name": "",                       
           "template_support": true,      
           "size": {                       
               "width": 12,
               "height": 5
           },
           "form_class": "WidgetForm", 
           "js_class": "CWidget",         
           "use_time_selector": false,    
           "refresh_rate": 60             
       }

url

A link to the module description.

Type: String

Example:

"url": "http://example.com"