Source
for (const threshold of this._thresholds_table.querySelectorAll('.form_row input[name$="[threshold]"')) {
<?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 Widgets\Gauge\Widget;
?>
window.widget_gauge_form = new class {
/**
* @type {HTMLFormElement}
*/
#form;
init({thresholds_colors}) {
this.#form = document.getElementById('widget-dialogue-form');
this.#form.addEventListener('change', () => this.#updateForm());
$thresholds_table.on('afterremove.dynamicRows', () => this.#updateForm());
this._thresholds_table = $thresholds_table[0];
this._thresholds_table.addEventListener('input', (e) => {
if (e.target.matches('input[name$="[threshold]"')) {
this.#updateForm();
}
});
for (const colorpicker of this.#form.querySelectorAll('.<?= ZBX_STYLE_COLOR_PICKER ?> input')) {
$(colorpicker).colorpicker({
appendTo: '.overlay-dialogue-body',
use_default: !colorpicker.name.includes('thresholds')
});
}
colorPalette.setThemeColors(thresholds_colors);
this.#updateForm();
}
#updateForm() {
const description_show = document.getElementById(`show_${<?= Widget::SHOW_DESCRIPTION ?>}`);
const value_show = document.getElementById(`show_${<?= Widget::SHOW_VALUE ?>}`);
const needle_show = document.getElementById(`show_${<?= Widget::SHOW_NEEDLE ?>}`);
const scale_show = document.getElementById(`show_${<?= Widget::SHOW_SCALE ?>}`);
const value_arc_show = document.getElementById(`show_${<?= Widget::SHOW_VALUE_ARC ?>}`);
const units_show = document.getElementById('units_show');
const th_show_arc = document.getElementById('th_show_arc');
const filled_thresholds_count = this.#countFilledThresholds();