Source
const display_as_is = ($('[name="display"]:checked').val() == <?= CWidgetFieldColumnsList::DISPLAY_AS_IS ?>);
<?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/>.
**/
use Zabbix\Widgets\Fields\CWidgetFieldColumnsList;
?>
window.tophosts_column_edit_form = new class {
init({form_name, thresholds, thresholds_colors}) {
this._$widget_form = $(`form[name="${form_name}"]`);
this._$thresholds_table = this._$widget_form.find('#thresholds_table');
$('[name="data"], [name="aggregate_function"], [name="display"], [name="history"]', this._$widget_form)
.on('change', () => this._update());
colorPalette.setThemeColors(thresholds_colors);
this._$thresholds_table.dynamicRows({
rows: thresholds,
template: '#thresholds-row-tmpl',
allow_empty: true,
dataCallback: (row_data) => {
if (!('color' in row_data)) {
const colors = this._$widget_form[0].querySelectorAll('.<?= ZBX_STYLE_COLOR_PICKER ?> input');
const used_colors = [];
for (const color of colors) {
if (color.value !== '') {
used_colors.push(color.value);
}
}
row_data.color = colorPalette.getNextColor(used_colors);
}
}
});
$('tr.form_row input[name$="[color]"]', this._$thresholds_table).each((i, colorpicker) => {
$(colorpicker).colorpicker({appendTo: $(colorpicker).closest('.input-color-picker')});
});
this._$thresholds_table
.on('afteradd.dynamicRows', e => {
const $colorpicker = $('tr.form_row:last input[name$="[color]"]', e.target);
$colorpicker.colorpicker({appendTo: $colorpicker.closest('.input-color-picker')});
this._update();