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

2. Часы

Description

These parameters and the possible property values for the respective dashboard widget field objects allow to configure the Clock widget in dashboard.create and dashboard.update methods.

Parameters

The following parameters are supported for the Clock widget.

Parameter type name value
Refresh interval 0 rf_rate 0 - No refresh;
10 - 10 seconds;
30 - 30 seconds;
60 - 1 minute;
120 - 2 minutes;
600 - 10 minutes;
900 - (default) 15 minutes.
Time type 0 time_type 0 - (default) Local time;
1 - Server time;
2 - Host time.
Clock type 0 clock_type 0 - (default) Analog;
1 - Digital.

The following parameters are supported if Time type is set to "Host time".

Parameter type name value
Item
(required)
4 itemid Item ID.

The following parameters are supported if Clock type is set to "Digital".

Parameter type name value
Show 0 show 1 - Date;
2 - (default) Time;
3 - Time zone.

Note: To configure multiple values, create a dashboard widget field object for each value.
Advanced configuration 0 adv_conf 0 - (default) Disabled;
1 - Enabled.

Parameter Advanced configuration must be set to "Enabled" to configure Background color and all options for Date, Time and Time zone.
Background color 1 bg_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Date
Size 0 date_size Valid values range from 1-100.

Default: 20.
Bold 0 date_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 date_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Time
Size 0 time_size Valid values range from 1-100.

Default: 30.
Bold 0 time_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 time_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Seconds 0 time_sec 0 - Disabled;
1 - (default) Enabled.
Format 0 time_format 0 - (default) 24-hour;
1 - 12-hour.
Time zone
Size 0 tzone_size Valid values range from 1-100.

Default: 20.
Bold 0 tzone_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 tzone_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Time zone 1 tzone_timezone Valid timezone string (e.g. Europe/Riga, system, UTC, etc.). For the full list of supported time zones please refer to PHP documentation.

Default: local.

Parameter Time zone not available if Time type is set to "Host time".
Format 0 tzone_format 0 - (default) Short;
1 - Full.

Parameter Format not available if Time type is set to "Host time".

Advanced configuration

The following advanced configuration parameters are supported if Clock type is set to "Digital".

Parameter type name value
Background color 1 bg_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Date

The following advanced configuration parameters are supported if Clock type is set to "Digital", and Show is set to "Date".

Parameter type name value
Size 0 date_size Valid values range from 1-100.

Default: 20.
Bold 0 date_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 date_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Time

The following advanced configuration parameters are supported if Clock type is set to "Digital", and Show is set to "Time".

Parameter type name value
Size 0 time_size Valid values range from 1-100.

Default: 30.
Bold 0 time_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 time_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Seconds 0 time_sec 0 - Disabled;
1 - (default) Enabled.
Format 0 time_format 0 - (default) 24-hour;
1 - 12-hour.
Time zone

The following advanced configuration parameters are supported if Clock type is set to "Digital", and Show is set to "Time zone".

Parameter type name value
Size 0 tzone_size Valid values range from 1-100.

Default: 20.
Bold 0 tzone_bold 0 - (default) Disabled;
1 - Enabled.
Color 1 tzone_color Hexadecimal color code (e.g. FF0000).

Default: "" (empty).
Time zone 1 tzone_timezone Valid timezone string (e.g. Europe/Riga, system, UTC, etc.). For the full list of supported time zones please refer to PHP documentation.

Default: local.

Parameter Time zone not available if Time type is set to "Host time".
Format 0 tzone_format 0 - (default) Short;
1 - Full.

Parameter Format not available if Time type is set to "Host time".

Examples

The following examples aim to only describe the configuration of the dashboard widget field objects for the Clock widget. For more information on configuring a dashboard, see dashboard.create.

Configuring a Clock widget

Configure a Clock widget that displays local date, time and time zone in a customized digital clock.

Request:

{
           "jsonrpc": "2.0",
           "method": "dashboard.create",
           "params": {
               "name": "My dashboard",
               "display_period": 30,
               "auto_start": 1,
               "pages": [
                   {
                       "widgets": [
                           {
                               "type": "clock",
                               "name": "Clock",
                               "x": 0,
                               "y": 0,
                               "width": 4,
                               "height": 3,
                               "view_mode": 0,
                               "fields": [
                                   {
                                       "type": 0,
                                       "name": "clock_type",
                                       "value": 1
                                   },
                                   {
                                       "type": 0,
                                       "name": "show",
                                       "value": 1
                                   },
                                   {
                                       "type": 0,
                                       "name": "show",
                                       "value": 2
                                   },
                                   {
                                       "type": 0,
                                       "name": "show",
                                       "value": 3
                                   },
                                   {
                                       "type": 0,
                                       "name": "adv_conf",
                                       "value": 1
                                   },
                                   {
                                       "type": 0,
                                       "name": "date_size",
                                       "value": 20
                                   },
                                   {
                                       "type": 1,
                                       "name": "date_color",
                                       "value": "E1E1E1"
                                   },
                                   {
                                       "type": 0,
                                       "name": "time_bold",
                                       "value": 1
                                   },
                                   {
                                       "type": 0,
                                       "name": "tzone_size",
                                       "value": 10
                                   },
                                   {
                                       "type": 1,
                                       "name": "tzone_color",
                                       "value": "E1E1E1"
                                   },
                                   {
                                       "type": 1,
                                       "name": "tzone_timezone",
                                       "value": "Europe/Riga"
                                   },
                                   {
                                       "type": 0,
                                       "name": "tzone_format",
                                       "value": 1
                                   }
                               ]
                           }
                       ]
                   }
               ],
               "userGroups": [
                   {
                       "usrgrpid": 7,
                       "permission": 2
                   }
               ],
               "users": [
                   {
                       "userid": 1,
                       "permission": 3
                   }
               ]
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "dashboardids": [
                   "3"
               ]
           },
           "id": 1
       }

Смотрите также