Source
* @param string options['context'] Determines whether the menu is made for host or template item.
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
/**
* Get menu popup history section data.
*
* @param string options['itemid'] Item ID.
* @param bool options['hasLatestGraphs'] Link to history page with showgraph action (optional).
*
* @return array
*/
function getMenuPopupHistory(options) {
var items = [],
url = new Curl('history.php');
if (!options.allowed_ui_latest_data) {
return [];
}
url.setArgument('itemids[]', options.itemid);
// latest graphs
if (typeof options.hasLatestGraphs !== 'undefined' && options.hasLatestGraphs) {
url.setArgument('action', 'showgraph');
url.setArgument('to', 'now');
url.setArgument('from', 'now-1h');
items.push({
label: t('Last hour graph'),
url: url.getUrl()
});
url.setArgument('from', 'now-7d');
items.push({
label: t('Last week graph'),
url: url.getUrl()
});
url.setArgument('from', 'now-1M');
items.push({
label: t('Last month graph'),
url: url.getUrl()
});
}
// latest values
url.setArgument('action', 'showvalues');
url.setArgument('from', 'now-1h');
items.push({
label: t('Latest values'),
url: url.getUrl()
});
return [{
label: t('History'),
items: items
}];
}
/**
* Get menu popup host section data.
*
* @param {string} options['hostid'] Host ID.
* @param {array} options['scripts'] Host scripts (optional).
* @param {string} options['csrf_token'] CSRF token.
* @param {string} options[]['name'] Script name.
* @param {string} options[]['scriptid'] Script ID.
* @param {string} options[]['confirmation'] Confirmation text.
* @param {bool} options['showGraphs'] Link to Monitoring->Hosts->Graphs page.
* @param {bool} options['showDashboards'] Link to Monitoring->Hosts->Dashboards page.
* @param {bool} options['showWeb'] Link to Monitoring->Hosts->Web page.
* @param {bool} options['showTriggers'] Link to Monitoring->Problems page.
* @param {bool} options['hasGoTo'] "Go to" block in popup.
* @param {array} options['severities'] (optional)