Source
xxxxxxxxxx
<?php
/*
** 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/>.
**/
/**
* @var CView $this
*/
?>
window.trigger_edit_popup = new class {
init({triggerid, expression_popup_parameters, recovery_popup_parameters, readonly, dependencies, action,
context, db_trigger
}) {
this.triggerid = triggerid;
this.expression_popup_parameters = expression_popup_parameters;
this.recovery_popup_parameters = recovery_popup_parameters;
this.readonly = readonly;
this.dependencies = dependencies;
this.action = action;
this.context = context;
this.db_trigger = db_trigger;
this.overlay = overlays_stack.getById('trigger-edit');
this.dialogue = this.overlay.$dialogue[0];
this.form = this.overlay.$dialogue.$body[0].querySelector('form');
this.expression = this.form.querySelector('#expression');
this.expr_temp = this.form.querySelector('#expr_temp');
this.name = this.form.querySelector('#name');
this.recovery_expression = this.form.querySelector('#recovery_expression');
this.recovery_expr_temp = this.form.querySelector('#recovery_expr_temp');
this.expression_constructor_active = false;
this.recovery_expression_constructor_active = false;
this.selected_dependencies = [];
window.addPopupValues = (data) => {
this.addPopupValues(data.values);
}
this.form.style.display = '';
this.#initActions();
this.#initTriggersTab();
this.#changeRecoveryMode();
this.#changeCorrelationMode();
if (this.dependencies) {
this.#loadDependencyTable(this.dependencies);
}
this.overlay.recoverFocus();
}
#initActions() {
['input', 'keydown', 'paste'].forEach((event_type) => {
this.name.addEventListener(event_type,
(e) => {
this.form.querySelector('#event_name').placeholder = e.target.value;
$(this.form.querySelector('#event_name')).textareaFlexible('updateHeight');
}
);
this.name.dispatchEvent(new Event('input'));
});
// Form submit on Enter for event_name field, because textareaflexible.js triggers JQuery event.
this.form.querySelector('[name="event_name"]').addEventListener('keyup', e => {
if (e.key === 'Enter') {
$(this.form).submit();
}
});
// Tags tab events.
this.form.querySelectorAll('[name="show_inherited_tags"]')
.forEach(o => o.addEventListener('change', e => this.#toggleInheritedTags()));
this.form.addEventListener('click', (e) => {
if (e.target.id === 'expression-constructor' || e.target.id === 'close-expression-constructor') {
this.#toggleExpressionConstructor(e.target.id);
}
else if (e.target.id === 'insert-expression') {