diff options
author | Alexander Vladishev <aleksander.vladishev@zabbix.com> | 2022-07-07 09:21:13 +0300 |
---|---|---|
committer | Alexander Vladishev <aleksander.vladishev@zabbix.com> | 2022-07-07 09:21:13 +0300 |
commit | 931e073f3053f80810ff77a779d557f8af1d64e2 (patch) | |
tree | 5aba868764e0fbeaad74292e1ba8fa650da645a3 | |
parent | 3ec9e898a6e03b45cd4479089f944abfc400545a (diff) | |
parent | df0b42cf0258f2e5611a69cf964fcf485edab700 (diff) |
..F....... [ZBX-20584] fixed possibility to open graph in a full screen from graph widget
* commit 'df0b42cf0258f2e5611a69cf964fcf485edab700':
..F....... [ZBX-20584] fixed graph links for templated dashboards
..F....... [ZBX-20584] fixed possibility to open graph in a full screen from graph widget
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-20584 | 1 | ||||
-rw-r--r-- | ui/app/controllers/CControllerWidgetGraphView.php | 53 |
2 files changed, 28 insertions, 26 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-20584 b/ChangeLog.d/bugfix/ZBX-20584 new file mode 100644 index 00000000000..ceaad27a872 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-20584 @@ -0,0 +1 @@ +..F....... [ZBX-20584] fixed possibility to open graph in a full screen from graph widget (Sasha) diff --git a/ui/app/controllers/CControllerWidgetGraphView.php b/ui/app/controllers/CControllerWidgetGraphView.php index 82ac42643e9..ea69a05caa7 100644 --- a/ui/app/controllers/CControllerWidgetGraphView.php +++ b/ui/app/controllers/CControllerWidgetGraphView.php @@ -92,7 +92,7 @@ class CControllerWidgetGraphView extends CControllerWidget { $is_dynamic_item = ($is_template_dashboard || $fields['dynamic'] == WIDGET_DYNAMIC_ITEM); // Replace graph item by particular host item if dynamic items are used. - if ($is_dynamic_item && $dynamic_hostid && $resourceid) { + if ($is_dynamic_item && $dynamic_hostid != 0 && $resourceid) { // Find same simple-graph item in selected $dynamic_hostid host. if ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_SIMPLE_GRAPH) { $src_items = API::Item()->get([ @@ -218,7 +218,7 @@ class CControllerWidgetGraphView extends CControllerWidget { // get graph, used below $graph = API::Graph()->get([ 'output' => API_OUTPUT_EXTEND, - 'selectHosts' => ['name'], + 'selectHosts' => ['hostid', 'name'], 'graphids' => $resourceid, 'expandName' => true ]); @@ -267,7 +267,7 @@ class CControllerWidgetGraphView extends CControllerWidget { ? $graph['hosts'][0]['name'].NAME_DELIMITER.$graph['name'] : $graph['name']; - if ($is_dynamic_item && $dynamic_hostid && $resourceid) { + if ($is_dynamic_item && $dynamic_hostid != 0 && $resourceid) { if ($graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED) { $graph_src = (new CUrl('chart7.php')) ->setArgument('name', $host['name'].NAME_DELIMITER.$graph['name']) @@ -341,30 +341,31 @@ class CControllerWidgetGraphView extends CControllerWidget { } else { if ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_GRAPH) { - if ($is_dynamic_item && $dynamic_hostid) { - $template_graphs = API::Graph()->get([ - 'output' => ['name'], - 'graphids' => [$resourceid] - ]); - - $resourceid = null; - - if ($template_graphs) { - $host_graphs = API::Graph()->get([ - 'output' => ['graphid'], - 'hostids' => [$dynamic_hostid], - 'filter' => [ - 'name' => $template_graphs[0]['name'] - ] - ]); - - if ($host_graphs) { - $resourceid = $host_graphs[0]['graphid']; - } - } + $has_host_graph = $is_dynamic_item && $dynamic_hostid != 0 + ? (bool) API::Graph()->get([ + 'output' => [], + 'hostids' => [$dynamic_hostid], + 'filter' => [ + 'name' => $graph['name'] + ] + ]) + : true; + + if ($has_host_graph) { + $graph_url = $this->checkAccess(CRoleHelper::UI_MONITORING_HOSTS) + ? (new CUrl('zabbix.php')) + ->setArgument('action', 'charts.view') + ->setArgument('filter_hostids', [$graph['hosts'][0]['hostid']]) + ->setArgument('filter_name', $graph['name']) + ->setArgument('filter_show', GRAPH_FILTER_HOST) + ->setArgument('filter_set', '1') + ->setArgument('from', '') + ->setArgument('to', '') + : null; + } + else { + $graph_url = null; } - - $graph_url = null; } else { $graph_url = $this->checkAccess(CRoleHelper::UI_MONITORING_LATEST_DATA) |