Commit 26c115f2 by Torkel Ödegaard

more efficient closing of full edit/view mode

parent fcb6b333
...@@ -259,29 +259,19 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -259,29 +259,19 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
return $scope.panel.auto_int && interval === $scope.panel.interval ? interval+" (auto)" : interval; return $scope.panel.auto_int && interval === $scope.panel.interval ? interval+" (auto)" : interval;
}; };
/** $scope.updateTimeRange = function () {
* The time range effecting the panel $scope.range = filterSrv.timeRange();
* @return {[type]} [description] $scope.interval = $scope.panel.interval;
*/
$scope.get_time_range = function () {
var range = $scope.range = filterSrv.timeRange();
return range;
};
$scope.get_interval = function () {
var interval = $scope.panel.interval;
var range;
if ($scope.panel.auto_int) { if ($scope.panel.auto_int) {
range = $scope.get_time_range(); if ($scope.range) {
if (range) { $scope.interval = kbn.secondsToHms(
interval = kbn.secondsToHms( kbn.calculate_interval($scope.range, $scope.range, $scope.panel.resolution, 0) / 1000
kbn.calculate_interval(range.from, range.to, $scope.panel.resolution, 0) / 1000
); );
} }
} }
$scope.panel.interval = interval || '10m'; $scope.panel.interval = $scope.interval || '10m';
return $scope.panel.interval; $scope.interval = $scope.panel.interval;
}; };
$scope.colors = [ $scope.colors = [
...@@ -308,11 +298,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -308,11 +298,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.panelMeta.loading = true; $scope.panelMeta.loading = true;
var range = $scope.get_time_range(); $scope.updateTimeRange();
var interval = $scope.get_interval(range);
var graphiteQuery = { var graphiteQuery = {
range: range, range: $scope.range,
targets: $scope.panel.targets, targets: $scope.panel.targets,
maxDataPoints: $scope.panel.span * 50 maxDataPoints: $scope.panel.span * 50
}; };
...@@ -320,7 +309,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -320,7 +309,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
return graphiteSrv.query(graphiteQuery) return graphiteSrv.query(graphiteQuery)
.then(function(results) { .then(function(results) {
$scope.panelMeta.loading = false; $scope.panelMeta.loading = false;
var data = $scope.receiveGraphiteData(results, range, interval); var data = $scope.receiveGraphiteData(results);
$scope.$emit('render', data); $scope.$emit('render', data);
}) })
.then(null, function(err) { .then(null, function(err) {
...@@ -328,7 +317,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -328,7 +317,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}); });
}; };
$scope.receiveGraphiteData = function(results, range, interval) { $scope.receiveGraphiteData = function(results) {
results = results.data; results = results.data;
$scope.legend = []; $scope.legend = [];
var data = []; var data = [];
...@@ -338,9 +327,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -338,9 +327,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
} }
var tsOpts = { var tsOpts = {
interval: interval, interval: $scope.interval,
start_date: range && range.from, start_date: $scope.range && $scope.range.from,
end_date: range && range.to, end_date: $scope.range && $scope.range.to,
fill_style: 'no' fill_style: 'no'
}; };
...@@ -383,6 +372,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -383,6 +372,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.enterFullscreenMode = function(options) { $scope.enterFullscreenMode = function(options) {
var oldHeight = $scope.row.height; var oldHeight = $scope.row.height;
var docHeight = $(window).height(); var docHeight = $(window).height();
var oldTimeRange = $scope.range;
$scope.row.height = options.edit ? 200 : Math.floor(docHeight * 0.7); $scope.row.height = options.edit ? 200 : Math.floor(docHeight * 0.7);
$scope.editMode = options.edit; $scope.editMode = options.edit;
...@@ -396,7 +386,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -396,7 +386,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
closeEditMode(); closeEditMode();
$timeout(function() { $timeout(function() {
$scope.dashboard.refresh(); $scope.$emit('render');
if (oldTimeRange !== $scope.range) {
$scope.dashboard.refresh();
}
}); });
}); });
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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