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
|
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace Widgets\HostNavigator\Includes;
use Zabbix\Widgets\{
CWidgetField,
CWidgetForm
};
use Zabbix\Widgets\Fields\{
CWidgetFieldCheckBox,
CWidgetFieldPatternSelectHost,
CWidgetFieldIntegerBox,
CWidgetFieldMultiSelectGroup,
CWidgetFieldMultiSelectOverrideHost,
CWidgetFieldRadioButtonList,
CWidgetFieldSeverities,
CWidgetFieldTags
};
/**
* Host navigator widget form.
*/
class WidgetForm extends CWidgetForm {
public const HOST_STATUS_ANY = -1;
public const HOST_STATUS_ENABLED = 0;
public const HOST_STATUS_DISABLED = 1;
public const PROBLEMS_ALL = 0;
public const PROBLEMS_UNSUPPRESSED = 1;
public const PROBLEMS_NONE = 2;
private const LINES_MIN = 1;
private const LINES_MAX = 9999;
private const LINES_DEFAULT = 100;
public function addFields(): self {
return $this
->addField($this->isTemplateDashboard()
? null
: new CWidgetFieldMultiSelectGroup('groupids', _('Host groups'))
)
->addField($this->isTemplateDashboard()
? null
: new CWidgetFieldPatternSelectHost('hosts', _('Host patterns'))
)
->addField($this->isTemplateDashboard()
? null
: (new CWidgetFieldRadioButtonList('status', _('Host status'), [
self::HOST_STATUS_ANY => _('Any'),
self::HOST_STATUS_ENABLED => _('Enabled'),
self::HOST_STATUS_DISABLED => _('Disabled')
]))->setDefault(self::HOST_STATUS_ANY)
)
->addField($this->isTemplateDashboard()
? null
: (new CWidgetFieldRadioButtonList('host_tags_evaltype', _('Host tags'), [
TAG_EVAL_TYPE_AND_OR => _('And/Or'),
TAG_EVAL_TYPE_OR => _('Or')
]))->setDefault(TAG_EVAL_TYPE_AND_OR)
)
->addField($this->isTemplateDashboard()
? null
: new CWidgetFieldTags('host_tags')
)
->addField(
new CWidgetFieldSeverities('severities', _('Severity'))
)
->addField(
new CWidgetFieldCheckBox('maintenance',
$this->isTemplateDashboard() ? _('Show data in maintenance') : _('Show hosts in maintenance')
)
)
->addField(
(new CWidgetFieldRadioButtonList('problems', _('Show problems'), [
self::PROBLEMS_ALL => _('All'),
self::PROBLEMS_UNSUPPRESSED => _('Unsuppressed'),
self::PROBLEMS_NONE => _('None')
]))->setDefault(self::PROBLEMS_UNSUPPRESSED)
)
->addField(
new CWidgetFieldHostGrouping('group_by', _('Group by'))
)
->addField($this->isTemplateDashboard()
? null
: (new CWidgetFieldIntegerBox('show_lines', _('Host limit'), self::LINES_MIN, self::LINES_MAX))
->setDefault(self::LINES_DEFAULT)
->setFlags(CWidgetField::FLAG_NOT_EMPTY | CWidgetField::FLAG_LABEL_ASTERISK)
)
->addField(
new CWidgetFieldMultiSelectOverrideHost()
);
}
}
|