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 29$this->includeJsFile('monitoring.host.view.js.php'); 30 31$this->enableLayoutModes(); 32$web_layout_mode = $this->getLayoutMode(); 33 34$widget = (new CWidget()) 35 ->setTitle(_('Hosts')) 36 ->setWebLayoutMode($web_layout_mode) 37 ->setControls( 38 (new CTag('nav', true, (new CList())->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode])))) 39 ->setAttribute('aria-label', _('Content controls')) 40 ); 41 42$filter_tags = $data['filter']['tags']; 43if (!$filter_tags) { 44 $filter_tags = [['tag' => '', 'value' => '', 'operator' => TAG_OPERATOR_LIKE]]; 45} 46 47$filter_tags_table = (new CTable()) 48 ->setId('filter-tags') 49 ->addRow( 50 (new CCol( 51 (new CRadioButtonList('filter_evaltype', (int) $data['filter']['evaltype'])) 52 ->addValue(_('And/Or'), TAG_EVAL_TYPE_AND_OR) 53 ->addValue(_('Or'), TAG_EVAL_TYPE_OR) 54 ->setModern(true) 55 ))->setColSpan(4) 56); 57 58$i = 0; 59foreach ($filter_tags as $tag) { 60 $filter_tags_table->addRow([ 61 (new CTextBox('filter_tags['.$i.'][tag]', $tag['tag'])) 62 ->setAttribute('placeholder', _('tag')) 63 ->setWidth(ZBX_TEXTAREA_FILTER_SMALL_WIDTH), 64 (new CRadioButtonList('filter_tags['.$i.'][operator]', (int) $tag['operator'])) 65 ->addValue(_('Contains'), TAG_OPERATOR_LIKE) 66 ->addValue(_('Equals'), TAG_OPERATOR_EQUAL) 67 ->setModern(true), 68 (new CTextBox('filter_tags['.$i.'][value]', $tag['value'])) 69 ->setAttribute('placeholder', _('value')) 70 ->setWidth(ZBX_TEXTAREA_FILTER_SMALL_WIDTH), 71 (new CCol( 72 (new CButton('filter_tags['.$i.'][remove]', _('Remove'))) 73 ->addClass(ZBX_STYLE_BTN_LINK) 74 ->addClass('element-table-remove') 75 ))->addClass(ZBX_STYLE_NOWRAP) 76 ], 'form_row'); 77 78 $i++; 79} 80$filter_tags_table->addRow( 81 (new CCol( 82 (new CButton('filter_tags_add', _('Add'))) 83 ->addClass(ZBX_STYLE_BTN_LINK) 84 ->addClass('element-table-add') 85 ))->setColSpan(3) 86); 87 88$severities = []; 89foreach (range(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_COUNT - 1) as $severity) { 90 $severities[] = [ 91 'name' => getSeverityName($severity, $data['config']), 92 'value' => $severity 93 ]; 94} 95 96if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { 97 $widget->addItem((new CFilter((new CUrl('zabbix.php'))->setArgument('action', 'host.view'))) 98 ->setProfile('web.hostsmon.filter') 99 ->setActiveTab($data['active_tab']) 100 ->addFormItem((new CVar('action', 'host.view'))->removeId()) 101 ->addFilterTab(_('Filter'), [ 102 (new CFormList()) 103 ->addRow(_('Name'), 104 (new CTextBox('filter_name', $data['filter']['name']))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 105 ) 106 ->addRow((new CLabel(_('Host groups'), 'filter_groupids__ms')), 107 (new CMultiSelect([ 108 'name' => 'filter_groupids[]', 109 'object_name' => 'hostGroup', 110 'data' => $data['multiselect_hostgroup_data'], 111 'popup' => [ 112 'parameters' => [ 113 'srctbl' => 'host_groups', 114 'srcfld1' => 'groupid', 115 'dstfrm' => 'zbx_filter', 116 'dstfld1' => 'filter_groupids_', 117 'real_hosts' => true, 118 'enrich_parent_groups' => true 119 ] 120 ] 121 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 122 ) 123 ->addRow(_('IP'), 124 (new CTextBox('filter_ip', $data['filter']['ip'])) 125 ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 126 ) 127 ->addRow(_('DNS'), 128 (new CTextBox('filter_dns', $data['filter']['dns'])) 129 ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 130 ) 131 ->addRow(_('Port'), 132 (new CTextBox('filter_port', $data['filter']['port'])) 133 ->setWidth(ZBX_TEXTAREA_INTERFACE_PORT_WIDTH) 134 ) 135 ->addRow(_('Severity'), 136 (new CSeverityCheckBoxList('filter_severities'))->setChecked($data['filter']['severities']) 137 ), 138 (new CFormList()) 139 ->addRow(_('Status'), 140 (new CRadioButtonList('filter_status', (int) $data['filter']['status'])) 141 ->addValue(_('Any'), -1) 142 ->addValue(_('Enabled'), HOST_STATUS_MONITORED) 143 ->addValue(_('Disabled'), HOST_STATUS_NOT_MONITORED) 144 ->setModern(true) 145 ) 146 ->addRow(_('Tags'), $filter_tags_table) 147 ->addRow(_('Show hosts in maintenance'), [ 148 (new CCheckBox('filter_maintenance_status')) 149 ->setChecked($data['filter']['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) 150 ->setUncheckedValue(HOST_MAINTENANCE_STATUS_OFF), 151 (new CDiv([ 152 (new CLabel(_('Show suppressed problems'), 'filter_show_suppressed')) 153 ->addClass(ZBX_STYLE_SECOND_COLUMN_LABEL), 154 (new CCheckBox('filter_show_suppressed')) 155 ->setChecked($data['filter']['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE) 156 ->setUncheckedValue(ZBX_PROBLEM_SUPPRESSED_FALSE) 157 ->setEnabled($data['filter']['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) 158 ]))->addClass(ZBX_STYLE_TABLE_FORMS_SECOND_COLUMN) 159 ]) 160 ]) 161 ); 162} 163 164$widget->addItem(new CPartial('monitoring.host.view.html', array_intersect_key($data, array_flip([ 165 'filter', 'sort', 'sortorder', 'view_curl', 'hosts', 'config', 'maintenances', 'paging' 166])))); 167 168$widget->show(); 169 170(new CScriptTag('host_page.start();')) 171 ->setOnDocumentReady() 172 ->show(); 173