mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added shortcut to zoom out (ctrl+z)
This commit is contained in:
parent
ebf1db7545
commit
55467e26a9
@ -3,7 +3,6 @@ define([
|
||||
'./dashLoader',
|
||||
'./row',
|
||||
'./pulldown',
|
||||
'./zoom',
|
||||
'./search',
|
||||
'./metricKeys',
|
||||
'./graphiteTarget'
|
||||
|
@ -91,6 +91,10 @@ function (angular, $, config, _) {
|
||||
dashboard.refresh();
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('ctrl+z', function(evt) {
|
||||
$rootScope.$emit('zoom-out', evt);
|
||||
}, { inputDisabled: true });
|
||||
|
||||
keyboardManager.bind('esc', function() {
|
||||
var popups = $('.popover.in');
|
||||
if (popups.length > 0) {
|
||||
|
@ -7,7 +7,7 @@ function (angular, _) {
|
||||
|
||||
var module = angular.module('kibana.controllers');
|
||||
|
||||
module.controller('dashLoader', function($scope, $rootScope, $http, timer, dashboard, alertSrv, $location) {
|
||||
module.controller('dashLoader', function($scope, $rootScope, $http, dashboard, alertSrv, $location, filterSrv) {
|
||||
$scope.loader = dashboard.current.loader;
|
||||
|
||||
$scope.init = function() {
|
||||
@ -18,6 +18,10 @@ function (angular, _) {
|
||||
$rootScope.$on('save-dashboard', function() {
|
||||
$scope.elasticsearch_save('dashboard', false);
|
||||
});
|
||||
|
||||
$rootScope.$on('zoom-out', function() {
|
||||
$scope.zoom(2);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showDropdown = function(type) {
|
||||
@ -131,6 +135,35 @@ function (angular, _) {
|
||||
});
|
||||
};
|
||||
|
||||
// function $scope.zoom
|
||||
// factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan
|
||||
$scope.zoom = function(factor) {
|
||||
var _range = filterSrv.timeRange('last');
|
||||
var _timespan = (_range.to.valueOf() - _range.from.valueOf());
|
||||
var _center = _range.to.valueOf() - _timespan/2;
|
||||
|
||||
var _to = (_center + (_timespan*factor)/2);
|
||||
var _from = (_center - (_timespan*factor)/2);
|
||||
|
||||
// If we're not already looking into the future, don't.
|
||||
if(_to > Date.now() && _range.to < Date.now()) {
|
||||
var _offset = _to - Date.now();
|
||||
_from = _from - _offset;
|
||||
_to = Date.now();
|
||||
}
|
||||
|
||||
if(factor > 1) {
|
||||
filterSrv.removeByType('time');
|
||||
}
|
||||
|
||||
filterSrv.set({
|
||||
type:'time',
|
||||
from:moment.utc(_from).toDate(),
|
||||
to:moment.utc(_to).toDate(),
|
||||
field:"@timestamp"
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,45 +0,0 @@
|
||||
define([
|
||||
'angular',
|
||||
'app',
|
||||
'underscore',
|
||||
'moment',
|
||||
],
|
||||
function (angular, app, _, moment) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('kibana.controllers');
|
||||
|
||||
module.controller('ZoomCtrl', function($scope, filterSrv) {
|
||||
|
||||
// function $scope.zoom
|
||||
// factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan
|
||||
$scope.zoom = function(factor) {
|
||||
var _range = filterSrv.timeRange('last');
|
||||
var _timespan = (_range.to.valueOf() - _range.from.valueOf());
|
||||
var _center = _range.to.valueOf() - _timespan/2;
|
||||
|
||||
var _to = (_center + (_timespan*factor)/2);
|
||||
var _from = (_center - (_timespan*factor)/2);
|
||||
|
||||
// If we're not already looking into the future, don't.
|
||||
if(_to > Date.now() && _range.to < Date.now()) {
|
||||
var _offset = _to - Date.now();
|
||||
_from = _from - _offset;
|
||||
_to = Date.now();
|
||||
}
|
||||
|
||||
if(factor > 1) {
|
||||
filterSrv.removeByType('time');
|
||||
}
|
||||
|
||||
filterSrv.set({
|
||||
type:'time',
|
||||
from:moment.utc(_from).toDate(),
|
||||
to:moment.utc(_to).toDate(),
|
||||
field:"@timestamp"
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -55,11 +55,11 @@ function (angular) {
|
||||
'{{panel.title}}' +
|
||||
'</span>' +
|
||||
'<ul class="dropdown-menu" role="menu">' +
|
||||
'<li ng-repeat="item in panelMenuItems"><a ng-click="item.action();">{{item.text}}</a></li>' +
|
||||
'<li ng-repeat="item in panelMeta.menuItems"><a ng-click="item.action();">{{item.text}}</a></li>' +
|
||||
'</ul>' +
|
||||
'</span>'+
|
||||
|
||||
'<span ng-if="!panelMenuItems" class="row-button row-text panel-title pointer" ng-show="panel.title">' +
|
||||
'<span ng-if="!panelMeta.menuItems" class="row-button row-text panel-title pointer" ng-show="panel.title">' +
|
||||
'{{panel.title}}' +
|
||||
'</span>'+
|
||||
|
||||
|
@ -56,9 +56,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
],
|
||||
|
||||
menuItems: [
|
||||
{ text: 'View fullscreen', action: $scope.toggleFullscreen },
|
||||
{ text: 'Edit', action: $scope.openConfigureModal },
|
||||
{ text: 'Duplicate', action: $scope.duplicate }
|
||||
{ text: 'View fullscreen', action: function() { $scope.toggleFullscreen(); }},
|
||||
{ text: 'Edit', action: function() { $scope.openConfigureModal(); }},
|
||||
{ text: 'Duplicate', action: function() { $scope.duplicate(); }},
|
||||
{ text: 'Remove', action: function() { $scope.remove_panel_from_row($scope.row, $scope.panel); }}
|
||||
],
|
||||
|
||||
status : "Unstable",
|
||||
@ -212,12 +213,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
|
||||
$scope.init = function() {
|
||||
|
||||
$scope.panelMenuItems = [
|
||||
{ text: 'View fullscreen', action: $scope.toggleFullscreen },
|
||||
{ text: 'Edit', action: $scope.openConfigureModal },
|
||||
{ text: 'Duplicate', action: $scope.duplicate }
|
||||
];
|
||||
|
||||
// Hide view options by default
|
||||
$scope.options = false;
|
||||
$scope.editor = {index: 1};
|
||||
|
@ -5,7 +5,7 @@
|
||||
</style>
|
||||
|
||||
<li>
|
||||
<a class='small' ng-controller="ZoomCtrl" ng-click='zoom(2)'>
|
||||
<a class='small' ng-click='zoom(2)'>
|
||||
Zoom Out
|
||||
</a>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user