diff --git a/public/app/core/routes/routes.ts b/public/app/core/routes/routes.ts index 487e9deef27..baf77c32b30 100644 --- a/public/app/core/routes/routes.ts +++ b/public/app/core/routes/routes.ts @@ -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', { diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index cd52155ff5f..2f4668e3667 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -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) }); + }; + }); }); diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts index 28c4d3f05aa..abf48ad0b23 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -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) { diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index b543e933b90..8fbde9e84a1 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -157,7 +157,7 @@ class GraphCtrl extends MetricsPanelCtrl { } zoomOut(evt) { - this.publishAppEvent('zoom-out', evt); + this.publishAppEvent('zoom-out', 2); } onDataSnapshotLoad(snapshotData) {