Merge branch 'v3.1.x'

This commit is contained in:
Torkel Ödegaard 2016-07-27 09:36:46 +02:00
commit e4592c8d53
4 changed files with 23 additions and 17 deletions

View File

@ -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', {

View File

@ -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) });
};
});
});

View File

@ -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) {

View File

@ -157,7 +157,7 @@ class GraphCtrl extends MetricsPanelCtrl {
}
zoomOut(evt) {
this.publishAppEvent('zoom-out', evt);
this.publishAppEvent('zoom-out', 2);
}
onDataSnapshotLoad(snapshotData) {