1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22/**
23 * @var CView $this
24 */
25
26include dirname(__FILE__).'/js/monitoring.sysmaps.js.php';
27
28// create menu
29$menu = (new CList())
30	->addClass(ZBX_STYLE_OBJECT_GROUP)
31	->addItem([
32		_('Map element').':&nbsp;',
33		(new CButton('selementAdd', _('Add')))->addClass(ZBX_STYLE_BTN_LINK),
34		'&nbsp;/&nbsp;',
35		(new CButton('selementRemove', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)
36	])
37	->addItem([
38		_('Shape').':&nbsp;',
39		(new CButton('shapeAdd', _('Add')))->addClass(ZBX_STYLE_BTN_LINK),
40		'&nbsp;/&nbsp;',
41		(new CButton('shapesRemove', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)
42	])
43	->addItem([
44		_('Link').':&nbsp;',
45		(new CButton('linkAdd', _('Add')))->addClass(ZBX_STYLE_BTN_LINK),
46		'&nbsp;/&nbsp;',
47		(new CButton('linkRemove', _('Remove')))->addClass(ZBX_STYLE_BTN_LINK)
48	])
49	->addItem([
50		_('Expand macros').':&nbsp;',
51		(new CButton('expand_macros',
52			($this->data['sysmap']['expand_macros'] == SYSMAP_EXPAND_MACROS_ON) ? _('On') : _('Off')
53		))->addClass(ZBX_STYLE_BTN_LINK)
54	])
55	->addItem([
56		_('Grid').':&nbsp;',
57		(new CButton('gridshow',
58			($data['sysmap']['grid_show'] == SYSMAP_GRID_SHOW_ON) ? _('Shown') : _('Hidden')
59		))->addClass(ZBX_STYLE_BTN_LINK),
60		'&nbsp;/&nbsp;',
61		(new CButton('gridautoalign',
62			($data['sysmap']['grid_align'] == SYSMAP_GRID_ALIGN_ON) ? _('On') : _('Off')
63		))->addClass(ZBX_STYLE_BTN_LINK)
64	])
65	->addItem((new CSelect('gridsize'))
66		->setId('gridsize')
67		->setValue($data['sysmap']['grid_size'])
68		->addOptions(CSelect::createOptionsFromArray([
69			20 => '20x20',
70			40 => '40x40',
71			50 => '50x50',
72			75 => '75x75',
73			100 => '100x100'
74		]))
75	)
76	->addItem((new CButton('gridalignall', _('Align map elements')))->addClass(ZBX_STYLE_BTN_LINK))
77	->addItem((new CSubmit('update', _('Update')))->setId('sysmap_update'));
78
79$container = (new CDiv())->setId(ZBX_STYLE_MAP_AREA);
80
81// create elements
82zbx_add_post_js('ZABBIX.apps.map.run("'.ZBX_STYLE_MAP_AREA.'", '.json_encode([
83	'theme' => $data['theme'],
84	'sysmap' => $data['sysmap'],
85	'iconList' => $data['iconList'],
86	'defaultAutoIconId' => $data['defaultAutoIconId'],
87	'defaultIconId' => $data['defaultIconId'],
88	'defaultIconName' => $data['defaultIconName']
89], JSON_FORCE_OBJECT).');');
90
91(new CWidget())
92	->setTitle(_('Network maps'))
93	->addItem($menu)
94	->addItem(
95		(new CDiv(
96			(new CDiv())
97				->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)
98				->addItem($container)
99		))->addClass('sysmap-scroll-container')
100	)
101	->show();
102