From 70bca219e3b39fa04df7efe7d0a524795b2faa45 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 11 Apr 2017 10:24:21 +0300 Subject: [PATCH] graph(add annotation): Add keybinding for CTRL key --- public/app/plugins/panel/graph/graph.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 5aaf5324156..c9cd251777f 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -80,9 +80,11 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) { }, scope); appEvents.on('graph-click', (event) => { + // Add event only for selected panel + let thisPanelEvent = event.panel.id === ctrl.panel.id; // Select time for new annotation - if (ctrl.inAddAnnotationMode) { + if (ctrl.inAddAnnotationMode && thisPanelEvent) { let timeRange = { from: event.pos.x, to: null @@ -93,6 +95,22 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) { } }, scope); + // Add keybinding for Add Annotation mode + $(document).keydown(onCtrlKeyDown); + $(document).keyup(onCtrlKeyUp); + + function onCtrlKeyDown(event) { + if (event.key === 'Control') { + ctrl.inAddAnnotationMode = true; + } + } + + function onCtrlKeyUp(event) { + if (event.key === 'Control') { + ctrl.inAddAnnotationMode = false; + } + } + function getLegendHeight(panelHeight) { if (!panel.legend.show || panel.legend.rightSide) { return 0;