|
@@ -84,7 +84,8 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
|
|
|
let thisPanelEvent = event.panel.id === ctrl.panel.id;
|
|
let thisPanelEvent = event.panel.id === ctrl.panel.id;
|
|
|
|
|
|
|
|
// Select time for new annotation
|
|
// Select time for new annotation
|
|
|
- if (ctrl.inAddAnnotationMode && thisPanelEvent) {
|
|
|
|
|
|
|
+ let createAnnotation = ctrl.inAddAnnotationMode || event.pos.ctrlKey || event.pos.metaKey;
|
|
|
|
|
+ if (createAnnotation && thisPanelEvent) {
|
|
|
let timeRange = {
|
|
let timeRange = {
|
|
|
from: event.pos.x,
|
|
from: event.pos.x,
|
|
|
to: null
|
|
to: null
|
|
@@ -95,22 +96,6 @@ 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;
|
|
@@ -671,8 +656,8 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
elem.bind("plotselected", function (event, ranges) {
|
|
elem.bind("plotselected", function (event, ranges) {
|
|
|
- if (ctrl.inAddAnnotationMode) {
|
|
|
|
|
- // Select time range for new annotation
|
|
|
|
|
|
|
+ if (ctrl.inAddAnnotationMode || ranges.ctrlKey || ranges.metaKey) {
|
|
|
|
|
+ // Create new annotation from time range
|
|
|
let timeRange = ranges.xaxis;
|
|
let timeRange = ranges.xaxis;
|
|
|
ctrl.showAddAnnotationModal(timeRange);
|
|
ctrl.showAddAnnotationModal(timeRange);
|
|
|
plot.clearSelection();
|
|
plot.clearSelection();
|