Commit 55467e26 by Torkel Ödegaard

added shortcut to zoom out (ctrl+z)

parent ebf1db75
...@@ -3,7 +3,6 @@ define([ ...@@ -3,7 +3,6 @@ define([
'./dashLoader', './dashLoader',
'./row', './row',
'./pulldown', './pulldown',
'./zoom',
'./search', './search',
'./metricKeys', './metricKeys',
'./graphiteTarget' './graphiteTarget'
......
...@@ -91,6 +91,10 @@ function (angular, $, config, _) { ...@@ -91,6 +91,10 @@ function (angular, $, config, _) {
dashboard.refresh(); dashboard.refresh();
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+z', function(evt) {
$rootScope.$emit('zoom-out', evt);
}, { inputDisabled: true });
keyboardManager.bind('esc', function() { keyboardManager.bind('esc', function() {
var popups = $('.popover.in'); var popups = $('.popover.in');
if (popups.length > 0) { if (popups.length > 0) {
......
...@@ -7,7 +7,7 @@ function (angular, _) { ...@@ -7,7 +7,7 @@ function (angular, _) {
var module = angular.module('kibana.controllers'); 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.loader = dashboard.current.loader;
$scope.init = function() { $scope.init = function() {
...@@ -18,6 +18,10 @@ function (angular, _) { ...@@ -18,6 +18,10 @@ function (angular, _) {
$rootScope.$on('save-dashboard', function() { $rootScope.$on('save-dashboard', function() {
$scope.elasticsearch_save('dashboard', false); $scope.elasticsearch_save('dashboard', false);
}); });
$rootScope.$on('zoom-out', function() {
$scope.zoom(2);
});
}; };
$scope.showDropdown = function(type) { $scope.showDropdown = function(type) {
...@@ -131,6 +135,35 @@ function (angular, _) { ...@@ -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"
});
};
}); });
}); });
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"
});
};
});
});
\ No newline at end of file
...@@ -55,11 +55,11 @@ function (angular) { ...@@ -55,11 +55,11 @@ function (angular) {
'{{panel.title}}' + '{{panel.title}}' +
'</span>' + '</span>' +
'<ul class="dropdown-menu" role="menu">' + '<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>' + '</ul>' +
'</span>'+ '</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}}' + '{{panel.title}}' +
'</span>'+ '</span>'+
......
...@@ -56,9 +56,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -56,9 +56,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
], ],
menuItems: [ menuItems: [
{ text: 'View fullscreen', action: $scope.toggleFullscreen }, { text: 'View fullscreen', action: function() { $scope.toggleFullscreen(); }},
{ text: 'Edit', action: $scope.openConfigureModal }, { text: 'Edit', action: function() { $scope.openConfigureModal(); }},
{ text: 'Duplicate', action: $scope.duplicate } { text: 'Duplicate', action: function() { $scope.duplicate(); }},
{ text: 'Remove', action: function() { $scope.remove_panel_from_row($scope.row, $scope.panel); }}
], ],
status : "Unstable", status : "Unstable",
...@@ -212,12 +213,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -212,12 +213,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.init = function() { $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 // Hide view options by default
$scope.options = false; $scope.options = false;
$scope.editor = {index: 1}; $scope.editor = {index: 1};
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</style> </style>
<li> <li>
<a class='small' ng-controller="ZoomCtrl" ng-click='zoom(2)'> <a class='small' ng-click='zoom(2)'>
Zoom Out Zoom Out
</a> </a>
</li> </li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment