1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2016 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
$widget = (new CWidget())->setTitle(_('Dashboard'));
// create form
$form = (new CForm())
->setName('dashconf')
->setId('dashform')
->addVar('filterEnable', $this->data['isFilterEnable']);
// create form list
$form_list = new CFormList('dashconfFormList');
// append filter status to form list
if ($this->data['isFilterEnable']) {
$filterStatusSpan = (new CSpan(_('Enabled')))
->addClass(ZBX_STYLE_LINK_ACTION)
->addClass(ZBX_STYLE_GREEN)
->onClick("create_var('".$form->getName()."', 'filterEnable', 0, true);")
->setAttribute('tabindex', 0);
}
else {
$filterStatusSpan = (new CSpan(_('Disabled')))
->addClass(ZBX_STYLE_LINK_ACTION)
->addClass(ZBX_STYLE_RED)
->onClick("$('dashform').enable(); create_var('".$form->getName()."', 'filterEnable', 1, true);")
->setAttribute('tabindex', 0);
}
$form_list->addRow(_('Dashboard filter'), $filterStatusSpan);
// append host groups to form list
$hostGroupsComboBox = new CComboBox('grpswitch', $this->data['grpswitch'], 'submit()', [
0 => _('All'),
1 => _('Selected')
]);
if (!$this->data['isFilterEnable']) {
$hostGroupsComboBox->setAttribute('disabled', 'disabled');
}
$form_list->addRow(_('Host groups'), $hostGroupsComboBox);
if ($this->data['grpswitch']) {
$form_list->addRow(_('Show selected groups'), (new CMultiSelect([
'name' => 'groupids[]',
'objectName' => 'hostGroup',
'data' => $this->data['groups'],
'disabled' => !$this->data['isFilterEnable'],
'popup' => [
'parameters' => 'srctbl=host_groups&dstfrm='.$form->getName().'&dstfld1=groupids_'.
'&srcfld1=groupid&multiselect=1'
]
]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
$form_list->addRow(_('Hide selected groups'), (new CMultiSelect([
'name' => 'hidegroupids[]',
'objectName' => 'hostGroup',
'data' => $this->data['hideGroups'],
'disabled' => !$this->data['isFilterEnable'],
'popup' => [
'parameters' => 'srctbl=host_groups&dstfrm='.$form->getName().'&dstfld1=hidegroupids_'.
'&srcfld1=groupid&multiselect=1'
]
]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
}
// append host in maintenance checkbox to form list
$maintenanceCheckBox = (new CCheckBox('maintenance'))->setChecked($this->data['maintenance'] == 1);
if (!$this->data['isFilterEnable']) {
$maintenanceCheckBox->setAttribute('disabled', 'disabled');
}
$form_list->addRow(_('Hosts'),
new CLabel([$maintenanceCheckBox, _('Show hosts in maintenance')], 'maintenance')
);
// append trigger severities to form list
$severities = [];
foreach ($this->data['severities'] as $severity) {
$serverityCheckBox = (new CCheckBox('trgSeverity['.$severity.']'))
->setChecked(isset($this->data['severity'][$severity]))
->setEnabled($this->data['isFilterEnable']);
$severities[] = new CLabel([$serverityCheckBox, getSeverityName($severity, $this->data['config'])],
'trgSeverity['.$severity.']'
);
$severities[] = BR();
}
array_pop($severities);
$form_list->addRow(_('Triggers with severity'), $severities);
$form_list->addRow(_('Trigger name like'),
(new CTextBox('trigger_name', $data['trigger_name']))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setEnabled($data['isFilterEnable'])
);
if ($data['config']['event_ack_enable']) {
// append problem display to form list
$ext_ack_combobox = new CComboBox('extAck', $data['extAck'], null, [
EXTACK_OPTION_ALL => _('All'),
EXTACK_OPTION_BOTH => _('Separated'),
EXTACK_OPTION_UNACK => _('Unacknowledged only')
]);
$ext_ack_combobox->setEnabled($data['isFilterEnable']);
$form_list->addRow(_('Problem display'), $ext_ack_combobox);
}
// create tab
$tab = new CTabView();
$tab->addTab('dashconfTab', _('Filter'), $form_list);
$tab->setFooter(makeFormFooter(
new CSubmit('update', _('Update')),
[new CButtonCancel()]
));
$form->addItem($tab);
$widget->addItem($form);
return $widget;
|