mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
graph(add annotation): Add keybinding for CTRL key
This commit is contained in:
parent
d553498a33
commit
70bca219e3
@ -80,9 +80,11 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
|
|||||||
}, scope);
|
}, scope);
|
||||||
|
|
||||||
appEvents.on('graph-click', (event) => {
|
appEvents.on('graph-click', (event) => {
|
||||||
|
// Add event only for selected panel
|
||||||
|
let thisPanelEvent = event.panel.id === ctrl.panel.id;
|
||||||
|
|
||||||
// Select time for new annotation
|
// Select time for new annotation
|
||||||
if (ctrl.inAddAnnotationMode) {
|
if (ctrl.inAddAnnotationMode && thisPanelEvent) {
|
||||||
let timeRange = {
|
let timeRange = {
|
||||||
from: event.pos.x,
|
from: event.pos.x,
|
||||||
to: null
|
to: null
|
||||||
@ -93,6 +95,22 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
|
|||||||
}
|
}
|
||||||
}, scope);
|
}, 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) {
|
function getLegendHeight(panelHeight) {
|
||||||
if (!panel.legend.show || panel.legend.rightSide) {
|
if (!panel.legend.show || panel.legend.rightSide) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user