Source
* @param string options['context'] Determines whether the menu is made for host or template item.
/*
** 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/>.
**/
/**
* 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()