From 4b524fafa5e5e7164bbe67edc6317324c47a792d Mon Sep 17 00:00:00 2001 From: Dave Waters Date: Fri, 19 Oct 2018 16:33:23 -0400 Subject: [PATCH] initial work to add shortcut to toggle legend - generic --- public/app/core/components/help/help.ts | 1 + public/app/core/services/keybindingSrv.ts | 12 ++++++++++++ public/app/plugins/panel/graph/module.ts | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/core/components/help/help.ts b/public/app/core/components/help/help.ts index eac47b6e0a2..8e8a5ed45d2 100644 --- a/public/app/core/components/help/help.ts +++ b/public/app/core/components/help/help.ts @@ -34,6 +34,7 @@ export class HelpCtrl { { keys: ['p', 's'], description: 'Open Panel Share Modal' }, { keys: ['p', 'd'], description: 'Duplicate Panel' }, { keys: ['p', 'r'], description: 'Remove Panel' }, + { keys: ['p', 'l'], description: 'Toggle panel legend' }, ], 'Time Range': [ { keys: ['t', 'z'], description: 'Zoom out time range' }, diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index f43dc96cd37..6fe57dfa77a 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -242,6 +242,18 @@ export class KeybindingSrv { } }); + // toggle panel legend + this.bind('p l', () => { + if (dashboard.meta.focusPanelId) { + const panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId); + if (panelInfo.panel.legend) { + const panelRef = dashboard.getPanelById(dashboard.meta.focusPanelId); + panelRef.legend.show = !panelRef.legend.show; + panelRef.refresh(); + } + } + }); + // collapse all rows this.bind('d shift+c', () => { dashboard.collapseRows(); diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 07256164c56..5878473b4e6 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -147,7 +147,7 @@ class GraphCtrl extends MetricsPanelCtrl { onInitPanelActions(actions) { actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' }); - actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()' }); + actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()', shortcut: 'p l' }); } issueQueries(datasource) {