Source
const $macros = $('input[name^="macros"], textarea[name^="macros"]', this.$container).not(':disabled');
/*
** Zabbix
** 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 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.
**/
/**
* JavaScript class to manage host macros.
*/
class HostMacrosManager {
static ZBX_PROPERTY_OWN = 0x02;
static ZBX_MACRO_TYPE_TEXT = 0;
static ZBX_MACRO_TYPE_SECRET = 1;
static ZBX_MACRO_TYPE_VAULT = 2;
static ZBX_STYLE_ICON_TEXT = 'icon-text';
static ZBX_STYLE_ICON_INVISIBLE = 'icon-invisible';
static ZBX_STYLE_ICON_SECRET_TEXT = 'icon-secret';
static ZBX_STYLE_TEXTAREA_FLEXIBLE = 'textarea-flexible';
constructor({readonly, parent_hostid}) {
this.readonly = readonly;
this.parent_hostid = parent_hostid ?? null;
this.$container = $('#macros_container .table-forms-td-right');
}
load(show_inherited_macros, templateids) {
const url = new Curl('zabbix.php');
url.setArgument('action', 'hostmacros.list');
const post_data = {
macros: this.getMacros(),
show_inherited_macros: show_inherited_macros ? 1 : 0,
templateids: templateids,
readonly: this.readonly ? 1 : 0
};
if (this.parent_hostid !== null) {
post_data.parent_hostid = this.parent_hostid;
}
$.ajax(url.getUrl(), {
data: post_data,
dataType: 'json',
method: 'POST',
beforeSend: () => {
this.loaderStart();
}
})
.done((response) => {