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 26$this->addJsFile('multiselect.js'); 27$this->addJsFile('layout.mode.js'); 28$this->addJsFile('class.tagfilteritem.js'); 29 30$this->includeJsFile('monitoring.latest.view.js.php'); 31 32$this->enableLayoutModes(); 33$web_layout_mode = $this->getLayoutMode(); 34 35$widget = (new CWidget()) 36 ->setTitle(_('Latest data')) 37 ->setWebLayoutMode($web_layout_mode) 38 ->setControls( 39 (new CTag('nav', true, (new CList())->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode])))) 40 ->setAttribute('aria-label', _('Content controls')) 41 ); 42 43if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { 44 $filter_tags_table = CTagFilterFieldHelper::getTagFilterField([ 45 'evaltype' => $data['filter']['evaltype'], 46 'tags' => $data['filter']['tags'] 47 ]); 48 49 $widget->addItem((new CFilter((new CUrl('zabbix.php'))->setArgument('action', 'latest.view'))) 50 ->setProfile('web.latest.filter') 51 ->setActiveTab($data['active_tab']) 52 ->addFormItem((new CVar('action', 'latest.view'))->removeId()) 53 ->addFilterTab(_('Filter'), [ 54 (new CFormList()) 55 ->addRow((new CLabel(_('Host groups'), 'filter_groupids__ms')), 56 (new CMultiSelect([ 57 'name' => 'filter_groupids[]', 58 'object_name' => 'hostGroup', 59 'data' => $data['multiselect_hostgroup_data'], 60 'popup' => [ 61 'parameters' => [ 62 'srctbl' => 'host_groups', 63 'srcfld1' => 'groupid', 64 'dstfrm' => 'zbx_filter', 65 'dstfld1' => 'filter_groupids_', 66 'real_hosts' => true, 67 'enrich_parent_groups' => true 68 ] 69 ] 70 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 71 ) 72 ->addRow((new CLabel(_('Hosts'), 'filter_hostids__ms')), 73 (new CMultiSelect([ 74 'name' => 'filter_hostids[]', 75 'object_name' => 'hosts', 76 'data' => $data['multiselect_host_data'], 77 'popup' => [ 78 'filter_preselect_fields' => [ 79 'hostgroups' => 'filter_groupids_' 80 ], 81 'parameters' => [ 82 'srctbl' => 'hosts', 83 'srcfld1' => 'hostid', 84 'dstfrm' => 'zbx_filter', 85 'dstfld1' => 'filter_hostids_' 86 ] 87 ] 88 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 89 ) 90 ->addRow(_('Name'), 91 (new CTextBox('filter_select', $data['filter']['select'])) 92 ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 93 ), 94 (new CFormList()) 95 ->addRow(_('Tags'), $filter_tags_table) 96 ->addRow(_('Show details'), [ 97 (new CCheckBox('filter_show_details'))->setChecked($data['filter']['show_details'] == 1), 98 (new CDiv([ 99 (new CLabel(_('Show items without data'), 'filter_show_without_data')) 100 ->addClass(ZBX_STYLE_SECOND_COLUMN_LABEL), 101 (new CCheckBox('filter_show_without_data')) 102 ->setChecked($data['filter']['show_without_data'] == 1) 103 ->setAttribute('disabled', $data['filter']['hostids'] ? null : 'disabled') 104 ->setUncheckedValue(0) 105 ]))->addClass(ZBX_STYLE_TABLE_FORMS_SECOND_COLUMN) 106 ]) 107 ]) 108 ); 109} 110 111$widget->addItem(new CPartial('monitoring.latest.view.html', array_intersect_key($data, 112 array_flip(['filter', 'sort_field', 'sort_order', 'view_curl', 'paging', 'hosts', 'items', 'history', 'config', 113 'tags' 114 ]) 115))); 116 117$widget->show(); 118 119// Initialize page refresh. 120(new CScriptTag('latest_page.start();')) 121 ->setOnDocumentReady() 122 ->show(); 123