diff --git a/CHANGELOG b/CHANGELOG
index cd93e8fbae..8cfe30f60a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -435,6 +435,7 @@ Cacti CHANGELOG
-feature#7634: Add indexes for host-template and session lookup queries
-feature#7681: Add fail2ban support with a stable authentication-failure log line and a bundled filter
-feature#8281: Log user actions (create, delete, ...)
+-feature#8744: Allow users to keep graph action icons visible beside graphs
1.2.32
-security#GHSA-fq9x-x3vf-3vf2: Substitute data-input field tokens in a single pass so a composed value cannot re-inject an escaped payload into the script command line
diff --git a/include/css/graph_drilldown.css b/include/css/graph_drilldown.css
index 6ce4bebf8e..a296a86962 100644
--- a/include/css/graph_drilldown.css
+++ b/include/css/graph_drilldown.css
@@ -134,3 +134,46 @@
text-align: center;
vertical-align: middle;
}
+
+/* Reserve space beside the graph for users who prefer direct actions. */
+.graphWrapperOuter > div:first-child:has(> .graphDrillDownAlways) {
+ display: flex;
+ align-items: flex-start;
+}
+
+.graphWrapperOuter > div:first-child:has(> .graphDrillDownAlways) > .graphWrapper {
+ min-width: 0;
+}
+
+.graphDrillDownAlways {
+ position: static;
+ z-index: auto;
+ display: block;
+ flex: 0 0 24px;
+ width: 24px;
+ min-width: 24px;
+ height: auto;
+ padding: 10px 3px;
+}
+
+.graphDrillDownAlways .graphDrillDownMenu {
+ display: none;
+}
+
+.graphDrillDownAlways .iconWrapper {
+ display: block;
+ visibility: visible;
+ opacity: 1;
+}
+
+.graphDrillDownAlways .iconLink {
+ display: inline-block;
+ width: 24px;
+ line-height: 24px;
+ text-align: center;
+}
+
+.graphDrillDownAlways .iconLink:focus-visible {
+ outline: 2px solid currentColor;
+ outline-offset: 1px;
+}
diff --git a/include/global_settings.php b/include/global_settings.php
index c9a177bb30..39acf5320b 100644
--- a/include/global_settings.php
+++ b/include/global_settings.php
@@ -3173,6 +3173,16 @@ $settings_user = [
'default' => read_config_option('selected_theme'),
'array' => $themes
],
+ 'graph_actions_display' => [
+ 'friendly_name' => __('Graph Actions'),
+ 'description' => __('Show graph actions in a collapsed menu or as always-visible icons beside each graph.'),
+ 'method' => 'drop_array',
+ 'default' => 'menu',
+ 'array' => [
+ 'menu' => __('Collapsed Menu'),
+ 'icons' => __('Always-visible Icons')
+ ]
+ ],
'default_view_mode' => [
'friendly_name' => __('Default View Mode'),
'description' => __('Which Graph mode you want displayed by default when you first visit the Graphs page?'),
diff --git a/include/layout.js b/include/layout.js
index e90d0a3956..b544ad0921 100644
--- a/include/layout.js
+++ b/include/layout.js
@@ -940,6 +940,8 @@ function setupSelectmenuScrollClose() {
* that can't be set using a live attribute 'on()'
*/
function applySkin() {
+ labelVisibleGraphActions();
+
pageName = basename($(location).attr('pathname'));
$('#messageContainer').remove();
@@ -4924,12 +4926,41 @@ function refreshGraphs() {
});
}
+function labelVisibleGraphActions() {
+ // Visible icons keep their tooltips and also expose names to assistive technology.
+ $('.graphDrillDownAlways .iconWrapper a').each(function () {
+ var link = $(this);
+ var currentLabel = link.attr('aria-label');
+ var generatedLabel = link.attr('data-graph-action-label');
+ if (currentLabel && currentLabel !== generatedLabel) {
+ return;
+ }
+ var label = link.attr('title') || link.find('i[title], img[title]').first().attr('title');
+ if (label) {
+ link.attr('aria-label', label);
+ link.attr('data-graph-action-label', label);
+ }
+ });
+}
+
function initGraphDrilldown() {
// Common graph drilldown behaviour for every theme (styled in graph_drilldown.css).
// A hamburger glyph over the graph's top-right toggles the action icons; they
// close on a second click, on moving off the graph image, or on an outside click.
$(document).off('.graphdd');
+ labelVisibleGraphActions();
+
+ $(document).on('keydown.graphdd', function (event) {
+ if (event.keyCode == 27 && typeof spikeKillClose == 'function' && typeof spikeKillAnchor != 'undefined' && spikeKillAnchor) {
+ var anchor = $(spikeKillAnchor);
+ if (anchor.closest('.graphDrillDownAlways').length) {
+ spikeKillClose();
+ anchor.trigger('focus');
+ }
+ }
+ });
+
function closeGraphDrilldown(container) {
container.removeClass('open');
container.closest('.graphWrapperOuter').removeClass('graphDrillActive');
@@ -5334,6 +5365,7 @@ function initializeGraphs(disable_cache) {
if (realtimeArray[graph_id]) {
$('#wrapper_' + graph_id).html(keepRealtime[graph_id]).trigger('change');
$(this).html("");
+ labelVisibleGraphActions();
$('graph_id' + graph_id).tooltip().zoom({
inputfieldStartTime: 'date1',
@@ -5346,6 +5378,7 @@ function initializeGraphs(disable_cache) {
} else {
keepRealtime[graph_id] = $('#wrapper_' + graph_id).html();
$(this).html("");
+ labelVisibleGraphActions();
$(this).find('i').tooltip();
realtimeArray[graph_id] = true;
setFilters();
diff --git a/include/realtime.js b/include/realtime.js
index ae21fadece..f9630ee2f7 100644
--- a/include/realtime.js
+++ b/include/realtime.js
@@ -196,6 +196,7 @@ function stopRealtime() {
realtimeArray[graph_id] = false;
}
+ labelVisibleGraphActions();
setFilters();
tuneFilter();
}
diff --git a/lib/html.php b/lib/html.php
index ed178251a3..459e9f9eff 100644
--- a/lib/html.php
+++ b/lib/html.php
@@ -400,7 +400,7 @@ function html_graph_area(array &$graph_array, string $no_graphs_message = '', st
' graph_width='' graph_height='' title_font_size=''>
-
' class='noprint graphDrillDown graphDrillDownToggle'>
+
' class='noprint graphDrillDown '>
@@ -519,7 +519,7 @@ function html_graph_thumbnail_area(array &$graph_array, string $no_graphs_messag
' graph_width='' graph_height=''>
-
' class='noprint graphDrillDown graphDrillDownToggle'>
+
' class='noprint graphDrillDown '>
@@ -537,6 +537,11 @@ function html_graph_thumbnail_area(array &$graph_array, string $no_graphs_messag
print '
';
}
+/** Return the graph action layout selected by the current user. */
+function graph_drilldown_display_class() : string {
+ return read_user_setting('graph_actions_display') === 'icons' ? 'graphDrillDownAlways' : 'graphDrillDownToggle';
+}
+
/**
* Generates and prints HTML for graph drilldown icons.
*
@@ -2990,7 +2995,7 @@ function html_spikekill_js() : void {
}
spikeKillRequest = null;
- if (!$.contains(document, anchor[0]) || !anchor.closest('.graphDrillDownToggle').hasClass('open')) {
+ if (!$.contains(document, anchor[0]) || !anchor.closest('.graphDrillDownAlways, .graphDrillDownToggle.open').length) {
spikeKillAnchor = null;
return;
}
diff --git a/lib/html_graph.php b/lib/html_graph.php
index 0dd5b709c5..268291db7d 100644
--- a/lib/html_graph.php
+++ b/lib/html_graph.php
@@ -1906,7 +1906,7 @@ function html_graph_single_view() : void {
print "
";
if (is_realm_allowed(27)) {
- print "
";
+ print "
";
print "";
print "
";
@@ -2232,7 +2232,7 @@ function html_graph_zoom() : void {
' graph_id='' rra_id='' graph_width='= $graph_width ?>' graph_height='= $graph_height ?>' title_font_size='= $title_font_size ?>'>
-
' class='graphDrillDown graphDrillDownToggle noprint'>
+
' class='graphDrillDown noprint'>
_properties' class='iconLink properties'>
diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot
index 8686f08147..6ef10c2127 100644
--- a/locales/po/cacti.pot
+++ b/locales/po/cacti.pot
@@ -25494,3 +25494,15 @@ msgstr ""
#, php-format
msgid "Plugin %s installation failed. Its hooks are disabled. Review the plugin setup and Cacti log before enabling it."
msgstr ""
+
+#: include/global_settings.php
+msgid "Show graph actions in a collapsed menu or as always-visible icons beside each graph."
+msgstr ""
+
+#: include/global_settings.php
+msgid "Collapsed Menu"
+msgstr ""
+
+#: include/global_settings.php
+msgid "Always-visible Icons"
+msgstr ""
diff --git a/tests/Unit/Ui/Graph/GraphDrilldownMarkupTest.php b/tests/Unit/Ui/Graph/GraphDrilldownMarkupTest.php
index 12dc0f2207..f74ddf7cd1 100644
--- a/tests/Unit/Ui/Graph/GraphDrilldownMarkupTest.php
+++ b/tests/Unit/Ui/Graph/GraphDrilldownMarkupTest.php
@@ -10,5 +10,5 @@ test('graph action toggle retains its accessible button contract without a toolt
fclose($pipes[1]);
fclose($pipes[2]);
expect(proc_close($process))->toBe(0)->and($errors)->toBe('');
- expect(json_decode($output, true, 512, JSON_THROW_ON_ERROR)['passed'])->toBe(2);
+ expect(json_decode($output, true, 512, JSON_THROW_ON_ERROR)['passed'])->toBe(6);
});
diff --git a/tests/e2e/tests/graph-drilldown.spec.js b/tests/e2e/tests/graph-drilldown.spec.js
index b6e2be79a9..964c278058 100644
--- a/tests/e2e/tests/graph-drilldown.spec.js
+++ b/tests/e2e/tests/graph-drilldown.spec.js
@@ -13,7 +13,7 @@ test.beforeEach(async ({ page }) => {
await page.addStyleTag({ path: path.join(root, 'include/css/graph_drilldown.css') });
await page.addScriptTag({ path: path.join(root, 'include/js/jquery.js') });
const source = fs.readFileSync(path.join(root, 'include/layout.js'), 'utf8');
- const start = source.indexOf('function initGraphDrilldown()');
+ const start = source.indexOf('function labelVisibleGraphActions()');
const end = source.indexOf('\nfunction initializeGraphs', start);
expect(start).toBeGreaterThan(-1);
expect(end).toBeGreaterThan(start);
diff --git a/tests/e2e/tests/graph-spikekill.spec.js b/tests/e2e/tests/graph-spikekill.spec.js
index 7ec0307674..472b68cb61 100644
--- a/tests/e2e/tests/graph-spikekill.spec.js
+++ b/tests/e2e/tests/graph-spikekill.spec.js
@@ -48,7 +48,7 @@ async function setup(page, delay = 0) {
await page.addScriptTag({ path: path.join(root, 'include/js/jquery.js') });
await page.addScriptTag({ path: path.join(root, 'include/js/jquery-ui.js') });
const layout = fs.readFileSync(path.join(root, 'include/layout.js'), 'utf8');
- await page.addScriptTag({ content: sourceFunction(layout, 'initGraphDrilldown', 'initializeGraphs') + '\n//# sourceURL=http://cacti-fixture/include/layout.js' });
+ await page.addScriptTag({ content: sourceFunction(layout, 'labelVisibleGraphActions', 'initializeGraphs') + '\n//# sourceURL=http://cacti-fixture/include/layout.js' });
await page.addScriptTag({ content: sourceFunction(layout, 'removeSpikes', 'redrawGraph') + '\n//# sourceURL=http://cacti-fixture/include/layout.js' });
const php = fs.readFileSync(path.join(root, 'lib/html.php'), 'utf8');
const start = php.indexOf('\tvar spikeKillOpen = false;', php.indexOf('function html_spikekill_js()'));
diff --git a/tests/fixtures/Core/GraphDrilldownMarkup.php b/tests/fixtures/Core/GraphDrilldownMarkup.php
index 42e6c64a74..91d2598d87 100644
--- a/tests/fixtures/Core/GraphDrilldownMarkup.php
+++ b/tests/fixtures/Core/GraphDrilldownMarkup.php
@@ -33,6 +33,7 @@ function api_plugin_hook($type, $args) {
$GLOBALS['graph_markup_hook'] = $args;
}
\cacti_fixture_source_function(dirname(__DIR__, 3) . '/lib/html.php', 'graph_drilldown_icons', __NAMESPACE__);
+\cacti_fixture_source_function(dirname(__DIR__, 3) . '/lib/html.php', 'graph_drilldown_display_class', __NAMESPACE__);
if (!defined('CACTI_PATH_URL')) {
define('CACTI_PATH_URL', '/cacti/');
@@ -59,6 +60,14 @@ if (($argv[1] ?? '') === 'browser') {
exit;
}
+// Empty or unrecognised preferences retain the existing collapsed-menu default.
+foreach (['' => 'graphDrillDownToggle', 'menu' => 'graphDrillDownToggle', 'icons' => 'graphDrillDownAlways', '