mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
Merge branch 'v3.1.x'
This commit is contained in:
commit
e4592c8d53
@ -30,6 +30,7 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
.when('/dashboard-solo/:type/:slug', {
|
||||
templateUrl: 'public/app/features/panel/partials/soloPanel.html',
|
||||
controller : 'SoloPanelCtrl',
|
||||
reloadOnSearch: false,
|
||||
pageClass: 'page-dashboard',
|
||||
})
|
||||
.when('/dashboard/new', {
|
||||
|
@ -13,6 +13,8 @@ define([
|
||||
module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer) {
|
||||
var self = this;
|
||||
|
||||
$rootScope.onAppEvent('zoom-out', function(e, factor) { self.zoomOut(factor); }, $rootScope);
|
||||
|
||||
this.init = function(dashboard) {
|
||||
timer.cancel_all();
|
||||
|
||||
@ -137,6 +139,24 @@ define([
|
||||
return {from: from, to: to};
|
||||
};
|
||||
|
||||
this.zoomOut = function(factor) {
|
||||
var range = this.timeRange();
|
||||
|
||||
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 (to > Date.now() && range.to <= Date.now()) {
|
||||
var offset = to - Date.now();
|
||||
from = from - offset;
|
||||
to = Date.now();
|
||||
}
|
||||
|
||||
this.setTime({from: moment.utc(from), to: moment.utc(to) });
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -30,7 +30,6 @@ export class TimePickerCtrl {
|
||||
constructor(private $scope, private $rootScope, private timeSrv) {
|
||||
$scope.ctrl = this;
|
||||
|
||||
$rootScope.onAppEvent('zoom-out', () => this.zoom(2), $scope);
|
||||
$rootScope.onAppEvent('shift-time-forward', () => this.move(1), $scope);
|
||||
$rootScope.onAppEvent('shift-time-backward', () => this.move(-1), $scope);
|
||||
$rootScope.onAppEvent('refresh', () => this.init(), $scope);
|
||||
@ -75,21 +74,7 @@ export class TimePickerCtrl {
|
||||
}
|
||||
|
||||
zoom(factor) {
|
||||
var range = this.timeSrv.timeRange();
|
||||
|
||||
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 (to > Date.now() && range.to <= Date.now()) {
|
||||
var offset = to - Date.now();
|
||||
from = from - offset;
|
||||
to = Date.now();
|
||||
}
|
||||
|
||||
this.timeSrv.setTime({from: moment.utc(from), to: moment.utc(to) });
|
||||
this.$rootScope.appEvent('zoom-out', 2);
|
||||
}
|
||||
|
||||
move(direction) {
|
||||
|
@ -157,7 +157,7 @@ class GraphCtrl extends MetricsPanelCtrl {
|
||||
}
|
||||
|
||||
zoomOut(evt) {
|
||||
this.publishAppEvent('zoom-out', evt);
|
||||
this.publishAppEvent('zoom-out', 2);
|
||||
}
|
||||
|
||||
onDataSnapshotLoad(snapshotData) {
|
||||
|
Loading…
Reference in New Issue
Block a user