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
26if ($data['uncheck']) {
27	uncheckTableRows('dashboard');
28}
29$this->addJsFile('layout.mode.js');
30
31$this->enableLayoutModes();
32$web_layout_mode = $this->getLayoutMode();
33
34$widget = (new CWidget())
35	->setTitle(_('Dashboards'))
36	->setWebLayoutMode($web_layout_mode)
37	->setControls((new CTag('nav', true,
38		(new CList())
39			->addItem(new CRedirectButton(_('Create dashboard'),
40				(new CUrl('zabbix.php'))
41					->setArgument('action', 'dashboard.view')
42					->setArgument('new', '1')
43					->getUrl()
44			))
45		->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode]))
46		))
47		->setAttribute('aria-label', _('Content controls'))
48	);
49
50$form = (new CForm())->setName('dashboardForm');
51
52$table = (new CTableInfo())
53	->setHeader([
54		(new CColHeader(
55			(new CCheckBox('all_dashboards'))
56				->onClick("checkAll('".$form->getName()."', 'all_dashboards', 'dashboardids');")
57		))->addClass(ZBX_STYLE_CELL_WIDTH),
58		make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'],
59			(new CUrl('zabbix.php'))
60				->setArgument('action', 'dashboard.list')
61				->getUrl()
62		)
63	]);
64
65$url = (new CUrl('zabbix.php'))
66	->setArgument('action', 'dashboard.view')
67	->setArgument('dashboardid', '');
68
69foreach ($data['dashboards'] as $dashboard) {
70	$table->addRow([
71		(new CCheckBox('dashboardids['.$dashboard['dashboardid'].']', $dashboard['dashboardid']))
72			->setEnabled($dashboard['editable']),
73		new CLink($dashboard['name'],
74			$url
75				->setArgument('dashboardid', $dashboard['dashboardid'])
76				->getUrl()
77		)
78	]);
79}
80
81$form->addItem([
82	$table,
83	$data['paging'],
84	new CActionButtonList('action', 'dashboardids', [
85		'dashboard.delete' => ['name' => _('Delete'), 'confirm' => _('Delete selected dashboards?')]
86	], 'dashboard')
87]);
88
89$widget->addItem($form);
90$widget->show();
91