API - List of dashboard's blocks

Материал из WebHMI Wiki
Перейти к: навигация, поиск
Эта страница — перевод страницы API - Список блоков панелей. Перевод выполнен на 100%.

Другие языки:
English • ‎русский

To get a list of all dashboard's blocks, you must perform a GET request on the URL like this: http://192.168.1.1/api/blocks.

To obtain information about a particular block, you must perform a following GET request on a URL 'http://192.168.1.1/api/blocks/12' . Here "12" is the ID of the desired graph.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json


Example of a query for all blocks data:

URL: http://192.168.1.1/api/blocks
Method: GET

Headers:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of reply:

[
  {
    "id": "1",
    "dashboard_id": "1",
    "zindex": "1",
    "pos_left": "0",
    "pos_top": "0",
    "pos_width": "896",
    "pos_height": "445",
    "block_type": "Indicator",
    "title": "Фон",
    "url": "",
    "imageid": "1",
    "label": "",
    "align": "",
    "fontsize": "",
    "regid": "",
    "is_button": "false",
    "hide_value": "false",
    "start_value": "",
    "end_value": "",
    "colorize": "false"
  },
  {
    "id": "2",
    "dashboard_id": "1",
    "zindex": "3",
    "pos_left": "714",
    "pos_top": "277",
    "pos_width": "85",
    "pos_height": "25",
    "block_type": "TextValue",
    "title": "",
    "url": "",
    "imageid": "",
    "label": "",
    "align": "center",
    "fontsize": "4",
    "regid": "3",
    "is_button": "false",
    "hide_value": "false",
    "start_value": "",
    "end_value": "",
    "colorize": "false"
  },
  {
    "id": "3",
    "dashboard_id": "1",
    "zindex": "3",
    "pos_left": "450",
    "pos_top": "277",
    "pos_width": "110",
    "pos_height": "25",
    "block_type": "TextValue",
    "title": "",
    "url": "",
    "imageid": "",
    "label": "",
    "align": "left",
    "fontsize": "4",
    "regid": "5",
    "is_button": "",
    "hide_value": "",
    "start_value": "",
    "end_value": ""
  }
]


Example of query for block #1 information:

URL: http://192.168.1.1/api/blocks/1
Method: GET

Headers:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "1",
  "dashboard_id": "1",
  "zindex": "1",
  "pos_left": "0",
  "pos_top": "0",
  "pos_width": "896",
  "pos_height": "445",
  "block_type": "Indicator",
  "title": "Фон",
  "url": "",
  "imageid": "1",
  "label": "",
  "align": "",
  "fontsize": "",
  "regid": "",
  "is_button": "false",
  "hide_value": "false",
  "start_value": "",
  "end_value": "",
  "colorize": "false"
}


Block attributes:

idintUnique block identifier
dashboard_idstringBlock dashboard-owner identifier where the block is displayed
zindexintZ-index of block ("layer" number)
pos_leftintPosition on the dashboards from left edge in pixels
pos_topintPosition on the dashboards from top edge in pixels
pos_widthintBlock height in pixels
pos_heightintBlock width in pixels
block_typestring Block type. Options: Indicator, TextValue, Gauge
titlestringBlock name
urlstringURL for links
imageidintID of the image to display
labelstringText to be displayed in a block
alignstringText alignment Options: left, right, center
fontsizeintFont size, 1-5
regidintID of the source register for value
is_buttonint0 = user can change value, 1 = user can not change value
hide_valueint0 = display numeric value, 1 = don't display numeric value
start_valuedoubleStart point value for Gauge block
end_valuedoubleEnd point value for Gauge block
colorizeint0 = display block in black color, 1 = colrize block according to register's state