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